- Engineering
- Computer Science
- the exact same question i am reposting for the second...
Question: the exact same question i am reposting for the second...
Question details
The exact same question I am re-posting for the second time with no changes ( to speed up the process of getting an answer)..
Thanks.
https://www.Zookal.com/homework-help/questions-and-answers/include-include-using-std-cout-using-std-endl-class-node-friend-class-linkedlist-private-i-q34387564
- Implement insert() in tree.cpp and show the results of inserting 2, 1, 4, 5, 9, 3, 6, 7, 10, 12, 11 into an empty Binary search tree.
- Start with the tree in problem 1 and implement delete() and do:
- delete 4, then
- delete 9.
- Start with the tree in problem 2 and implement search() and do:
- Search 12
- Search 4
#include #include using std::cout; using std::endl; class Node { friend class LinkedList; private: int value; Node *left; Node *right; public: /* Constructors with No Arguments */ Node(void) : left(NULL), right(NULL) { } /* Constructors with a given value */ Node(int val) : value(val), left(NULL), right(NULL) { } /* Constructors with a given value and a link of the next node */ Node(int val, Node* next, Node* parent) : value(val), left(next), right(parent) {} /* Getters */ int getValue(void) { return value; } Node* getLeft(void) { return left; } Node* getRight(void) { return right; } }; /* definition of the linked list class */ class Tree { private: /* pointer of head node */ Node *root; /* pointer of tail node */ public: /* Constructors with No Arguments */ Tree(void); /* Constructors with a given value of a list node */ Tree(int val); /* Destructor */ ~Tree(void); /* Traversing the list and printing the value of each node */ void push_back(int val); }; Tree::Tree() { /* Initialize the head and tail node */ root = NULL; } Tree::Tree(int val) { /* Create a new node, acting as both the head and tail node */ root = new Node(val); } Tree::~Tree() { } void Tree::tree_Insert(int val){ /*Your code here*/ } void Tree::tree_Delete(int val){ /*Your code here*/ } void Tree::tree_Search(int val){ /*Your code here*/ } int main(int argc, const char * argv[]) { /*Your testing code here*/ }
Solution by an expert tutor
