Data Structures · Question 30 · Hard
A max-heap of 15 distinct keys is stored in array positions 1 to 15. How many of these positions could possibly hold the smallest key?
- 15
- 8
- 7
- 1
Answer and explanation
Answer: B. 8
Explanation: In a max-heap every parent is larger than its children, so the smallest key cannot have a child and must be a leaf. Positions 8 to 15 are the leaves, and any of them can hold it, so there are 8 positions.
Previous: The numbers 1, 2, 3, 4, 5 are pushed onto a stack in that order, and pops may…
Practise data structures
Try a fresh set of data structures questions with an explanation after every answer, free and without signing up: Data Structures practice. Or sit a full placement mock test.
More data structures questions
- A binary tree has preorder traversal A B D E H C F G and inorder traversal D B…
- The keys 10, 20, 30, 25, 28 are inserted in that order into an empty AVL tree…
- The numbers 1, 2, 3, 4, 5 are pushed onto a stack in that order, and pops may…
More technical & programming practice
Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge