Questions: Heaps and Priority Queues

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

You extract the minimum from a min-heap of 10 elements. What happens next in the heap's internal array representation?

AThe second-smallest element, which is always one of the root's children, automatically becomes the new root
BThe array is scanned linearly to find the next minimum, which is moved to index 0
CThe last element in the array is moved to the root position and sifted down by swapping with the smaller child until the heap property is restored
DThe left subtree of the root becomes the new heap, discarding the right subtree
Question 2 Multiple Choice

In a 0-indexed min-heap stored as an array, the node at index 7 has its parent at index:

A3
B6
C4
D13
Question 3 True / False

After inserting elements into a min-heap, the array representation contains the elements in sorted order from smallest to largest.

TTrue
FFalse
Question 4 True / False

A priority queue implemented as a min-heap supports O(1) access to the minimum element and O(log n) insertion and extraction.

TTrue
FFalse
Question 5 Short Answer

Why does a heap not guarantee that all elements are in sorted order, and how does this 'weak' ordering property actually make it more efficient for its intended use?

Think about your answer, then reveal below.