Consider the array A=<4, 1, 3, 2, 16, 9, 10, 14, 8, 7>. After building heap from the array A, the depth of the heap and the right child of max-heap are _________ and _________ respectively. (Root is at level 0).
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: B. 3, 10
Explanation
Build-heap on ⟨4, 1, 3, 2, 16, 9, 10, 14, 8, 7⟩ gives ⟨16, 14, 10, 8, 7, 9, 3, 2, 4, 1⟩. Ten nodes fill levels 0–3, so the depth is 3, and the root's right child is 10.
More Data Structures and Algorithms questions
- Which of the following algorithms solves the single-source shortest paths ?
- A text is made up of the characters A, B, C, D, E each occurring with the probability 0.08, 0.40, 0.25, 0.15 and 0.12 respectively. The opt…
- A binary search tree in which every non-leaf node has non-empty left and right subtrees is called a strictly binary tree. Such a tree with…
- Match the following with respect to algorithm paradigms :
- The maximum number of comparisons needed to sort 9 items using radix sort is (assume each item is 5 digit octal number) :
- A 5-ary tree is tree in which every internal node has exactly 5 children. The number of left nodes in such a tree with 8 internal nodes wil…