• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Heap Data Strcuture with Answers

Question 11

Given two max heaps of size n each, what is the minimum possible time complexity to make a one max-heap of size from elements of two max heaps?

  • O(n^2)

  • O(nLogLogn)

  • O(n)

  • O(nLogn)

Question 12

Which of the following Binary Min Heap operation has the highest time complexity?

  • Inserting an item under the assumption that the heap has capacity to accommodate one more item

  • Merging with another heap under the assumption that the heap has capacity to accommodate items of other heap

  • Deleting an item from heap

  • Decreasing value of a key

Question 13

A priority queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is: 10, 8, 5, 3, 2. Two new elements 1 and 7 are inserted into the heap in that order. The level-order traversal of the heap after the insertion of the elements is:

  • 10, 8, 7, 3, 2, 1, 5

  • 10, 8, 7, 2, 3, 1, 5

  • 10, 8, 7, 1, 2, 3, 5

  • 10, 8, 7, 5, 3, 2, 1

Question 14

Consider any array representation of an n element binary heap where the elements are stored from index 1 to index n of the array. For the element stored at index i of the array (i <= n), the index of the parent is

  • i - 1

  • floor(i/2)

  • ceiling(i/2)

  • (i+1)/2

Question 15

Consider a max heap, represented by the array: 40, 30, 20, 10, 15, 16, 17, 8, 4. Now consider that a value 35 is inserted into this heap. After insertion, the new heap is
  • 40, 30, 20, 10, 15, 16, 17, 8, 4, 35
  • 40, 35, 20, 10, 30, 16, 17, 8, 4, 15
  • 40, 30, 20, 10, 35, 16, 17, 8, 4, 15
  • 40, 35, 20, 10, 15, 16, 17, 8, 4, 30

Question 16

Consider the following array of elements. 〈89, 19, 50, 17, 12, 15, 2, 5, 7, 11, 6, 9, 100〉. The minimum number of interchanges needed to convert it into a max-heap is
  • 4
  • 5
  • 2
  • 3

Question 17

An operator delete(i) for a binary heap data structure is to be designed to delete the item in the i-th node. Assume that the heap is implemented in an array and i refers to the i-th index of the array. If the heap tree has depth d (number of edges on the path from the root to the farthest leaf), then what is the time complexity to re-fix the heap efficiently after the removal of the element?

  • O(1)

  • O(d) but not O(1)

  • O(2d) but not O(d)

  • O(d2d) but not O(2d)

Question 18

A complete binary min-heap is made by including each integer in [1, 1023] exactly once. The depth of a node in the heap is the length of the path from the root of the heap to that node. Thus, the root is at depth 0. The maximum depth at which integer 9 can appear is _____________

  • 6

  • 7

  • 8

  • 9

Question 19

Which of the following sequences of array elements forms a heap?

  • {23, 17, 14, 6, 13, 10, 1, 12, 7, 5}

  • {23, 17, 14, 6, 13, 10, 1, 5, 7, 12}

  • {23, 17, 14, 7, 13, 10, 1, 5, 6, 12}

  • {23, 17, 14, 7, 13, 10, 1, 12, 5, 7}

Question 20

The minimum number of interchanges needed to convert the array 89, 19, 40, 17, 12, 10, 2, 5, 7, 11, 6, 9, 70 into a heap with the maximum element at the root is

  • 0

  • 1

  • 2

  • 3

There are 30 questions to complete.

Last Updated :
Take a part in the ongoing discussion