Question
Write a C++ class that is a node for a binary tree. You can use BINNODE program (see Program Examples) as a start or write
Write a C++ class that is a node for a binary tree. You can use "BINNODE" program (see "Program Examples") as a start or write your own. You must use regular C++, no special libraries or templates for this project. Then declare 7 nodes to make a 7 node proper binary tree like the one in "Traversing " document. Write a function that takes 3 nodes and the data values and links two daughter nodes to a root. Then call the function to link 3 nodes, and call the function agaain as needed to make the rest of the tree .Then do a In Order traversal using the links. You can't jump between nodes which are not linked.Visist each node "In Order" display the data , and compare to finc the largest number. Display the largest number.
BINNODE Code included below
#include
class TreeNode { TreeNode *up; TreeNode *left; TreeNode *right; int value; public: void setup(TreeNode *p) { up = p;} void setleft(TreeNode *l) {left = l; } void setright(TreeNode *r) {right = r;} void setvalue(int v) {value = v; } int getvalue() {return value;} TreeNode getup() {return *up; } TreeNode getleft() {return *left; } TreeNode getright() {return *right; } }; TreeNode Make(TreeNode*, TreeNode*, TreeNode*, int , int, int ); int main() { TreeNode* TN1 = new TreeNode; TreeNode* TN2 = new TreeNode; TreeNode* TN3 = new TreeNode; system("pause"); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started