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)
Question 8 (15 Points): Given the following struct that represents a binary tree: struct Node ( }; int key; Node *parent
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am