Page 1 of 1

Question 8 (15 Points): Given the following struct that represents a binary tree: struct Node ( }; int key; Node *parent

Posted: Fri Jul 08, 2022 6:44 am
by answerhappygod
Question 8 15 Points Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent 1
Question 8 15 Points Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent 1 (42.17 KiB) Viewed 44 times
Question 8 15 Points Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent 2
Question 8 15 Points Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent 2 (29.19 KiB) Viewed 44 times
Question 8 15 Points Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent 3
Question 8 15 Points Given The Following Struct That Represents A Binary Tree Struct Node Int Key Node Parent 3 (29.19 KiB) Viewed 44 times
Question 8 (15 Points): Given the following struct that represents a binary tree: struct Node ( }; int key; Node *parent; Node *left; Node *right; Node (int k) key (k), parent (nullptr), left (nullptr), right (nullptr) ( Write a recursive function that prints out the nodes in a tree stored using m the above structure in order to cout. The function prints the depth (root depth is at 0) and key of that node separated by a colon (Example "0: 10\n" for root with key 10). Your function CAN NOT create any local variables and can only use what is passed to the function. Use the below function signature (NOTE: this is not a class method). void inorderWithDepth (Node *node, int depth)
Question 8 (15 Points) Given the following struct that represents a binary tree: struct Mode ( int key: Node "parent: Node left; Node right: Node (int k) key (k), parent (nullptr). left (mullpte), right (nullptr) (1 Write a recursive function that prints out the nodes in a tree stored using the above structure in order to cout. The function prints the depth (root depth is at 0) and key of that node separated by a colon (Example 0: 10\n" for root with key 10). Your function CAN NOT create any local variables and can only use what is passed to the function. Use the below function signature (NOTE: this is not a class method). void inorderWithDepth (Node node, int depth)