6. 11. Following problems are for the BimaruTree data structure with template. R
ID: 3848358 • Letter: 6
Question
6. 11. Following problems are for the BimaruTree data structure with template. Read the prob carefully and answer them. codes are parts of for deleting a node. template cclass T> class b Tree private: struct treeNode T value; The value in the node treeNode left: Pointer to left child node tree Node right: 1/ Pointer to right child node treeNode .root; Pointer to the root node void insert treeNode .R, treeNode .&) Private member functions void destroy SubTree (treeNode void deleteNode T. treeNode .&); Public: roots NULL; -binary Tree() destroy subTree (root): void insertNode(T): bool treeNode remove (int value treeNode void display Inorder (treeNode const: void display Preorder (treeNode consti void displayPostorderctreeNode const void iterative Preorder (troeNode conat template void binary Tree remove (treeNode .ktree) if (value this- value) if (left NULL) return left- removed value, this) else return NULL: else if (value this- value) if (right NULL) return right- remove value this) else return NULL else it (left NULL kk rights NULL) f this value right- ninvalue(); return right- remove value, this) else if (parent left this) Parent- left (left t- NULL) left right: return this: else if (parent- right this) parent-right (left NULL) left right return this;
Explanation / Answer
Hi,
1) Pre- order traversal for the tree would be -
31,20,15,22,23,36,33,32
2) Post- order traversal for the tree would be -
22,15,23,20,32,33,36,31
Answering the 2 questions based on chegg's rule.
NOTE - Please comment to understand more and asnwer more.
Thanks
Nikhil Jain
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.