All mock tests are FREE till 31 December — register to save your progress
Unit 7 · Data Structures and Algorithms Paper 2 CS · 22 June 2026

How will the following min-heap appear on inserting the key 32?
Original min-heap (level order): 5, 10, 25, 30, 40, 50, 60, 70, 80, 90 (root 5; children of 5 are 10 and 25; children of 10 are 30 and 40; children of 25 are 50 and 60; children of 30 are 70 and 80; the only child of 40 is 90).

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. After insertion the heap is re-arranged so that 10's children become 32 and 30, and 32's children become 90 and 40 (25's children remain 50 and 60)

Explanation

A heap is a complete binary tree, so the 11th node (32) is inserted at the next free slot in level order, which is the right child of 40 (sibling of 90). Since this is a min-heap and 32 10 (its new parent), so the heap property is satisfied and sifting stops. The final heap is: root 5; 5's children 10 and 25; 10's children become 32 and 30; 25's children remain 50 and 60; 32's children become 90 and 40; 30's children remain 70 and 80.

More Data Structures and Algorithms questions