Complete the C++ program and implement the routines that are n.docx Complete the C++ program and implement the routines that are n.docx Complete the C++ program and implement the routines that are n.docx Complete the C++ program and implement the routines that are n.docx Complete the C++ program and implement the routines that are n.docx Complete the C++ program and implement the routines that are n.docx
3. t.InsertIntoTree(t.TreeRoot, 22); t.InsertIntoTree(t.TreeRoot,
23); t.InsertIntoTree(t.TreeRoot, 24);
t.InsertIntoTree(t.TreeRoot, 25); t.InsertIntoTree(t.TreeRoot,
26); t.InsertIntoTree(t.TreeRoot, 11); cout << " Printing Pre
Order " << endl; t.PrintPreOrderTree(t.TreeRoot); cout << "
-----------------------------------------------" << endl; getchar();
cout << "Printing Post Order " << endl;
t.PrintPostOrderTree(t.TreeRoot); cout << " --------------------
---------------------------" << endl; getchar(); cout <<
"Printing In Order " << endl; t.PrintInOrderTree(t.TreeRoot);
cout << " -----------------------------------------------" << endl;
getchar(); cout << boolalpha << endl << endl; cout << "
Searching 30: " << t.Search(t.TreeRoot, 30) << endl; cout <<
" Searching 8: " << t.Search(t.TreeRoot, 8) << endl; cout <<
" Searching 10: " << t.Search(t.TreeRoot, 10) << endl; cout
<< "-------------------------------------------" << endl; getchar();
cout << "Printing Pre Order with Stack " << endl;
t.PrintPreOrderTreeWithStack(t.TreeRoot); cout << " ---------
--------------------------------------" << endl; getchar(); cout <<
"Printing level by level BreathFirst Traversal " << endl;
t.PrintBreadthFirstWithQueue(t.TreeRoot); cout << " ----------
-------------------------------------" << endl; getchar(); cout <<
endl; int MaxLen = t.FindMaxLen(t.TreeRoot); int MinLen =
t.FindMinLen(t.TreeRoot); int TotalNodes =
t.CountNodes(t.TreeRoot); cout << "Max is " << MaxLen <<
endl; cout << "Min is " << MinLen << endl; cout << "Num
of Nodes is " << TotalNodes << endl; cout << "-----------------
------------------------------" << endl; getchar(); Tree t2;
Copy(t.TreeRoot, t2.TreeRoot); cout << "Printing In Order the
copy of the tree" << endl; t2.PrintInOrderTree(t2.TreeRoot);
cout << " -----------------------------------------------" << endl;
} //---------------------------------------------------------------- /*
Your output should look like the foolowing Printing Pre Order
15-->10-->8-->9-->11-->20-->17-->21-->22-->23-->24-->25--
>26--> ----------------------------------------------- Printing Post
Order 9-->8-->11-->10-->17-->26-->25-->24-->23-->22-->21--
4. >20-->15--> ----------------------------------------------- Printing
In Order 8-->9-->10-->11-->15-->17-->20-->21-->22-->23--
>24-->25-->26--> -----------------------------------------------
Searching 30: false Searching 8: true Searching 10: true -------
------------------------------------ Printing Pre Order with Stack
15-->10-->8-->9-->11-->20-->17-->21-->22-->23-->24-->25--
>26--> ----------------------------------------------- Printing level
by level BreathFirst Traversal 15-->10-->20-->8-->11-->17--
>21-->9-->22-->23-->24-->25-->26--> -----------------------------
------------------ Max is 8 Min is 3 Num of Nodes is 13 ---------
-------------------------------------- Printing In Order the copy of
the tree 8-->9-->10-->11-->15-->17-->20-->21-->22-->23-->24-
->25-->26--> ----------------------------------------------- Press any
key to continue */
Solution
Implemented the following 4 functions
void Tree::InsertIntoTree(TreeStructPtr& Root, int x) {
if (Root == NULL) {
TreeStructPtr node = new TreeStruct();
node->Number = x;
node->Left = NULL;
node->Right = NULL;
Root = node;
} else {