Heaps and Priority Queues: past questions

19 questions · 59 marks · 10 papers. Try each one before checking.

Solve them and check answers →Read the notes first

03 Aug 2025

Question 3 MCQ · 4 marks

If we perform the following operations in the given order on the min-heap [11, 19, 12, 26, 32, 27, 20, 29, 37] then the resulting min-heap would be ___.

1 delete_min()
2 insert(18)

This question has a figure: open the interactive page.

  1. [12, 18, 20, 19, 32, 37, 27, 26, 29]

  2. [12, 18, 20, 19, 32, 27, 37, 29, 26]

  3. [12, 18, 19, 20, 27, 32, 37, 29, 26]

  4. [12, 20, 18, 19, 32, 27, 37, 26, 29]

Question 6 MCQ · 3 marks

Consider the max-heap [71, 46, 27, 37, 29, 17, 11, 32, 36] built by repeated insertion of values into an empty heap. Which of the following could not have been the last element inserted into this heap?

  1. 71

  2. 36

  3. 37

  4. 29

July 2022

Question 3 MCQ · 3 marks

A Priority-Queue is implemented as a Min-Heap. Initially, the Min-Heap is [7, 8, 11, 15, 20, 27]. Two new elements 9 and 5 are inserted in the given Min-Heap in that order. Min-Heap after the insertion of the elements is

This question has a figure: open the interactive page.

  1. [5, 7, 8, 9, 20, 27, 11, 15]

  2. [5, 7, 9, 8, 20, 27, 11, 15]

  3. [5, 7, 9, 8, 11, 20, 27, 15]

  4. [5, 7, 8, 9, 11, 15, 20, 27]

Question 10 MSQ · 3 marks

Which of the following statement(s) is/are true?

  1. The smallest element in a max-heap is always at a leaf node

  2. The smallest element in a max-heap is always at the lowest level

  3. The second-largest element in a max-heap is always a child of the root node

  4. Finding a minimum element in max-heap takes $O(\log n)$ time

  5. Insert a new element in max-heap takes $O(\log n)$ time in worst case

01 Dec 2024

Question 15 MSQ · 3 marks

Consider a min-heap with 45 distinct elements implemented using array $A$ with index 0 to 44. The largest element can not be in between

  1. A[11] and A[21] (both inclusive)

  2. A[0] and A[10] (both inclusive)

  3. A[31] and A[44] (both inclusive)

  4. A[22] and A[30] (both inclusive)

06 Apr 2026

Question 12 MSQ · 3 marks

Consider a min-heap implemented using an array with n distinct elements. Which of the following statements about the time complexity of operations on a min-heap is/are true in the worst case?

  1. Inserting a new element into a min-heap can be performed in $O(\log n)$ time.

  2. Finding the second minimum element in a min-heap can be performed in $O(1)$ time.

  3. Finding the maximum element in a min-heap can be performed in $O(\log n)$ time.

  4. Deleting the minimum element from a min-heap can be performed in $O(1)$ time.

Question 3 MCQ · 3 marks

Which of the following correctly represents the final max-heap after inserting elements 1, 2, 3, 5, 7, 6, and 4 in the given order one by one, starting with an empty heap? Note:- Ensure that the max-heap property is maintained after each insertion.

  1. 7, 6, 5, 1, 3, 4, 2

  2. 7, 5, 6, 1, 2, 3, 4

  3. 7, 6, 5, 4, 3, 2, 1

  4. 7, 5, 6, 1, 3, 2, 4

Aug 2023

Question 7 MSQ · 3 marks

Which of the following operation can be performed in $O(\log n)$ time on min-heap? Consider the size of min-heap is $n$ and implemented using an array.

  1. Inserting a new element

  2. Deleting the smallest element

  3. Update the value at the known index

  4. Finding the largest element

Question 6 MCQ · 4 marks

Consider a max-heap represented as the following list: [30, 20, 25, 5, 15, 23, 10, 3, 2] What are the leaf nodes of the resultant max-heap after the following operations are done on it?

  1. delete_max()
  2. Insert(24)

This question has a figure: open the interactive page.

  1. 2, 3, 5, 10, 15

  2. 2, 3, 10, 15, 23

  3. 2, 3, 5, 10, 20

  4. 2, 3, 5, 10, 23

Dec 2023

Question 4 MCQ · 3 marks

Consider a min-heap represented as the following list: [3, 6, 27, 65, 45, 33, 29, 72]. What would be the resultant min-heap after the following operations are done on it?

  1. delete_min()
  2. Insert(10)
  3. Insert(5)

This question has a figure: open the interactive page.

  1. [5, 6, 27, 10, 72, 29, 33, 65, 45]

  2. [5, 6, 27, 10, 72, 33, 29, 45, 65]

  3. [5, 6, 27, 72, 10, 33, 29, 45, 65]

  4. [5, 6, 27, 10, 72, 33, 29, 65, 45]

Question 15 MSQ · 3 marks

Which of the following statements is/are true about min-heap with distinct elements:

  1. The largest element in a min-heap is always at a leaf node.

  2. The largest element in a min-heap is always at the lowest level.

  3. The second-smallest element in a min-heap is always a child of the root node.

  4. Finding the largest element in min-heap takes $O(\log n)$ time.

16 Mar 2025

Question 13 MSQ · 3 marks

Which of the following arrays represent a valid min-heap when implemented as a 0-indexed array?

  1. [1, 3, 6, 5, 4, 9, 8, 7]

  2. [2, 4, 3, 8, 10, 15, 9, 6]

  3. [7, 10, 15, 20, 30, 16, 12, 22]

  4. [3, 6, 8, 10, 15, 9, 11, 20]

Question 14 SA · 3 marks

A binary heap is implemented using a 0-indexed array. The heap currently contains 100 elements. What is the index of the right child of the node at index 35?

Type your answer on the interactive page.

24 Mar 2024

Question 4 MCQ · 3 marks

You have a max-heap with the following set of elements: $\{10, 5, 15, 3, 8, 12\}$ Which of the following elements is guaranteed to be a child of the element 15?

  1. 10

  2. 5

  3. 12

  4. 8

04 Aug 2024

Question 6 MCQ · 3 marks

If we perform the following operations in the given order on the min-heap [1, 7, 13, 11, 9, 16, 21, 26, 19] then the resulting min-heap would be ___.

1 delete_min()
2 insert(6)

This question has a figure: open the interactive page.

  1. [6, 7, 13, 9, 19, 16, 21, 26, 11]

  2. [6, 7, 13, 9, 19, 16, 21, 11, 26]

  3. [6, 7, 13, 9, 19, 21, 16, 26, 11]

  4. [6, 7, 13, 9, 19, 21, 16, 11, 26]

Question 15 MSQ · 3 marks

Which of the following statements is/are true for Heap sort?

  1. The complexity of Heap sort is $O(n \log n)$ irrespective of the sequence of elements.

  2. The complexity of Heap sort is $O(n^2)$ in worst case and $O(n \log n)$ in best case.

  3. Heap Sort is an in-place sorting algorithm.

  4. Heap Sort is not a stable sorting algorithm because it does not maintain the relative order of equal elements.

Question 13 SA · 3 marks

What is the minimum number of elements possible in a binary heap with a height of 9? Consider the height of the empty binary heap is 0.

Type your answer on the interactive page.

14 Aug 2026

Question 4 MCQ · 3 marks

Consider a min-heap represented as the following list: [2, 5, 10, 15, 7, 20, 25, 18, 19] What are the leaf nodes of the resultant min-heap after the following operations are done on it?

  1. delete_min()
  2. insert(6)

This question has a figure: open the interactive page.

  1. 18, 15, 19, 20, 25

  2. 7, 18, 19, 20, 25

  3. 6, 18, 19, 20, 25

  4. 15, 18, 19, 7, 25

Question 5 MCQ · 3 marks

A standard max-heap contains $n$ elements. What is the worst-case time complexity of the most efficient algorithm for finding the minimum element in a standard max-heap?

  1. $O(1)$

  2. $O(\log n)$

  3. $O(n)$

  4. $O(n \log n)$

Check your answers →

Other PDSA topics