• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Heap Data Strcuture with Answers

Question 1

What is the time complexity of Build Heap operation? 
(Build Heap is used to build a max(or min) binary heap from a given array. Build Heap is used in Heap Sort as a first step for sorting.)

  • O(nLogn)

  • O(n^2)

  • O(n)

  • O(logn)

Question 2

A max-heap is a heap where the value of each parent is greater than or equal to the values of its children. Which of the following is a max-heap? (GATE CS 2011) .


gate_2011_2-(1)

  • A

  • B

  • C

  • D

Question 3

A 3-ary max heap is like a binary max heap, but instead of 2 children, nodes have 3 children. A 3-ary heap can be represented by an array as follows: The root is stored in the first location, a[0], nodes in the next level, from left to right, is stored from a[1] to a[3]. The nodes from the second level of the tree from left to right are stored from a[4] location onward. An item x can be inserted into a 3-ary heap containing n items by placing x in the location a[n] and pushing it up the tree to satisfy the heap property. Which one of the following is a valid sequence of elements in an array representing 3-ary max heap?

  • 1, 3, 5, 6, 8, 9

  • 9, 6, 3, 1, 8, 5

  • 9, 3, 6, 8, 5, 1

  • 9, 5, 6, 8, 3, 1

Question 4

Suppose the elements 7, 2, 10 and 4 are inserted, in that order, into the valid 3- ary max heap found in the above question, Which one of the following is the sequence of items in the array representing the resultant heap?

  • 10, 7, 9, 8, 3, 1, 5, 2, 6, 4

  • 10, 9, 8, 7, 6, 5, 4, 3, 2, 1

  • 10, 9, 4, 5, 7, 6, 8, 2, 1, 3

  • 10, 8, 6, 9, 7, 2, 3, 4, 1, 5

Question 5

Consider a binary max-heap implemented using an array. Which among the following arrays represents a binary max-heap? 
(More than one option correct)

  • 25,12,16,8,10,13,14

  • 25,12,16,13,10,8,14

  • 25,14,16,13,10,8,12

  • 25,14,12,13,10,8,16

Question 6

A min- Heap is a complete binary tree.

  • True

  • False

Question 7

We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is (A) theta(logn) (B) theta(n) (C) theta(nlogn) (D) theta(n^2)

  • A

  • B

  • C

  • D

Question 8

In a min-heap with n elements with the smallest element at the root, the 7th smallest element can be found in time:

  • theta(nlogn)

  • theta(n)

  • theta(logn)

  • theta(1)

Question 9

What are the necessary condition for a Tree to be a heap?

  • the tree must be complete.

  • Every Root value is greater or smaller than the children's value.

  • Both A and B

  • None

Question 10

The elements 32, 15, 20, 30, 12, 25, 16 are inserted one by one in the given order into a Max Heap. The resultant Max Heap is. 

tree


  • a

  • b

  • c

  • d

There are 30 questions to complete.

Last Updated :
Take a part in the ongoing discussion