Question 2 (20 Marks)Here is a small binary tree of integers that is needed for the next questions14/ \3 19/ \ / \2 6 16 30\ / \13 23 42a) Determine the depth of the tree? (4 Marks)b) True or False:i. Determine whether the tree is full or not. (3 Marks)ii. Determine whether the tree is complete or not. (3 Marks)
Question
Question 2 (20 Marks)Here is a small binary tree of integers that is needed for the next questions14/ \3 19/ \ / \2 6 16 30\ / \13 23 42a) Determine the depth of the tree? (4 Marks)b) True or False:i. Determine whether the tree is full or not. (3 Marks)ii. Determine whether the tree is complete or not. (3 Marks)
Solution
a) The depth of a tree is the maximum distance from the root node to any leaf node. In this case, the longest path from the root (14) to a leaf node is 14 -> 19 -> 30 -> 42. This path includes 4 nodes, so the depth of the tree is 4 - 1 = 3.
b) i. A full binary tree is a binary tree in which every node has either 0 or 2 children. In this tree, the node with value 19 has 3 children, so the tree is not full. Therefore, the answer is False.
ii. A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. In this tree, the second level is not completely filled (node 14 only has 2 children instead of the maximum possible 3), so the tree is not complete. Therefore, the answer is False.
Similar Questions
Question 1. [20 marks]Figure 1 Binary Tree(a) Given the binary tree in Figure 1, list the pre-order tree walk result.(b) Given the binary tree in Figure 1, list the in-order tree walk result
Problem statementsGiven a binary tree, find its height.Input FormatA single line of input contains string s which contains the node of the tree in level order fashion.'N' in the string represents NULL node.A string 5 1 1 2 N N 2 reprsents the tree 5 / \ 1 1 / \ 2 2Similarly a string 1 2 N 3 N represents the tree 1 / 2 / 3Constraints1 <= Number of nodes <= 10^51 <= Data of a node <= 10^5Output FormatPrint the height of the tree.Sample Input2 N 1 3 NSample Output3
.Question 8Which of the following are actual data structures? 1 pointB TreesC TreesA Trees
here are 8, 15, 13, 14 nodes were there in 4 different trees. Which of them could have formed a full binary tree?a) 8b) 15c) 13d) 14
What is the minimum number of nodes in a complete binary tree with depth 3?(A) 4(B) 5(C) 6(D) 7
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.