100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Presentation

COS2611 ASSESSMENT/ ASSIGNMENT 2 2023

Rating
-
Sold
3
Pages
13
Uploaded on
21-07-2023
Written in
2022/2023

100% WORKING SOLUTION FOR COS2611 ASSIGNMENT 2 2023

Institution
Course









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Course

Document information

Uploaded on
July 21, 2023
Number of pages
13
Written in
2022/2023
Type
Presentation
Person
Unknown

Subjects

Content preview

COS2611 ASSIGNMENT 3
//COPY CODE AND PASTE TO TEST

Question 1
// COS2611 Skeleton for Assessment 3
#include <iostream>
#include <fstream>
#include <string>
#include<vector>

//Add your student name and student number
//
//
//



using namespace std;

class TreeNode
{
//keep this class as is
public:

int value; //key or data
TreeNode* left;
TreeNode* right;

//constructors

TreeNode() {
value = 0;
left = NULL;
right = NULL;
} //default constructor

TreeNode(int v) {
value = v;
left = NULL;
right = NULL;
} //parametrized constructor

}; //TreeNode



class BST
{
public:
TreeNode* root;

, //member functions

BST() {
root = NULL;
}

bool isTreeEmpty()
{
if (root == NULL)
return true; //the tree is empty
else
return false; //the tree is not empty
}

void insertNode(TreeNode* new_node) {
if (root == NULL) {
root = new_node;
} //insert the root node
else {
TreeNode* temp = root;
while (temp != NULL) {
if (new_node->value == temp->value) {
cout << "Value Already exist," <<
"Insert another value!" << endl;
return;
}
else if ((new_node->value < temp->value) && (temp->left == NULL)) {
temp->left = new_node; //insert value to the left
break;
}
else if (new_node->value < temp->value) {
temp = temp->left;
}
else if ((new_node->value > temp->value) && (temp->right == NULL)) {
temp->right = new_node; //insert value to the right
break;
}
else {
temp = temp->right;
}
}
}
} //insertNode

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
foxNotes Acsess Business Academy
Follow You need to be logged in order to follow users or courses
Sold
112
Member since
2 year
Number of followers
63
Documents
35
Last sold
1 month ago
saveNotes

5.0

5 reviews

5
5
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions