# 500+ Heap (Data Structure) MCQs with FREE PDF

These Heap (Data Structure) MCQs contain questions and answers on heap, binary and weak heap, binomial and fibonacci heap, d ary heap, ternary heap, pairing and leftlist heap, skew heap, min and max heap. We have the best collection of Heap (Data Structure) MCQs and answer with FREE PDF. These Heap (Data Structure) MCQs will help you to prepare for any competitive exams like: BCA, MCA, GATE, GRE, IES, PSC, UGC NET, DOEACC Exams at all levels – you just have to practice regularly.

#### 1. For construction of a binary heap with property that parent node has value less than child node. In reference to that which line is incorrect. Line indexed from 1.

``````1. add(int k)
2. {
3.     heap_size++;
4.     int i = heap_size - 1;
5.     harr[i] = k;
6.     while (i != 0 && harr[parent(i)] < harr[i])
7.     {
8.             swap(&harr[i], &harr[parent(i)]);
9.             i = parent(i);
10.    }
11. }
``````

a) Line – 3

b) Line – 5

c) Line – 6

d) Line – 7

#### 2. What is the best case complexity in building a heap?

a) O(nlogn)

b) O(n2)

c) O(n*longn *logn)

d) O(n)

#### 3. Given an array of element 5, 7, 9, 1, 3, 10, 8, 4. Which of the following are the correct sequences of elements after inserting all the elements in a min-heap?

a) 1,3,4,5,7,8,9,10

b) 1,4,3,9,8,5,7,10

c) 1,3,4,5,8,7,9,10

d) 1,3,7,4,8,5,9,10

#### 4. State the complexity of algorithm given below.

``````	int function(vector<int> arr)
int len=arr.length();
if(len==0)
return;
temp=arr[len-1];
arr.pop_back();
return temp;
``````

a) o(n)

b) O(logn)

c) O(1)

d) O(n logn)

#### 5. What is the location of a parent node for any arbitary node i?

a) (i/2) position

b) (i+1)/ position

c) floor(i/2) position

d) ceil(i/2) position

#### 6. Given the code, choose the correct option that is consistent with the code. (Here A is the heap)

``````	build(A,i)
left-> 2*i
right->2*i +1
temp- > i
if(left<= heap_length[A] ans A[left] >A[temp])
temp -> left
if (right = heap_length[A] and A[right] > A[temp])
temp->right
if temp!= i
swap(A[i],A[temp])
build(A,temp)
``````

a) It is the build function of max heap

b) It is the build function of min heap

c) It is general build function of any heap

d) It is used to search element in any heap

Answer: It is the build function of max heap

a) O(logn)

b) O(n)

c) O(1)

d) O(nlogn)

#### 8. Which of these operations have same complexities?

a) Insertion, find_min

b) Find_min, union

c) Union, Insertion

d) Deletion, Find _max

a) True

b) False

a) n

b) n-1

c) n/2

d) logn

#### 11. Choose the option with function having same complexity for a fibonacci heap.

a) Insertion, Union

b) Insertion, Deletion

c) extract_min, insertion

d) Union, delete

#### 12. The main distinguishable characterstic of a binomial heap from a binary heap is that

a) it allows union operations very efficiently

b) it does not allow union operations that could easily be implemented in binary heap

c) the heap structure is not similar to complete binary tree

d) the location of child node is not fixed i.e child nodes could be at level (h-2) or (h-3), where h is height of heap and h>4

Answer: it allows union operations very efficiently

a) logn

b) n

c) nlogn

d) n/2

#### 14. In a binomial heap the root value is greater than left child and less than right child.

a) True

b) False

50+ Binary Heap MCQs with FREE PDF

a) merge

b) deletion

c) insertion

d) swapping

a) c

b) c+1

c) c-1

d) 1

a) binary heap

b) d-heap

c) treap

d) pairing heap

#### 18. Pairing heaps time complexity was inspired by that of?

a) splay tree

b) treap

c) red-black tree

d) avl tree

a) True

b) False

a) O(N)

b) O(log N)

c) O(N2)

d) O(M log N)

#### 21. Out of the following given options, which is the fastest algorithm?

a) fibonacci heap

b) pairing heap

c) d-ary heap

d) binary heap

#### 22. What is the run time efficiency of an insertion algorithm?

a) O(N)

b) O(log N)

c) O(N2)

d) O(M log N)

50+ Pairing Heap MCQs with FREE PDF

#### 23. The procedure FindMin() to find the minimum element and the procedure DeleteMin() to delete the minimum element in min heap take _________

a) logarithmic and linear time constant respectively

b) constant and linear time respectively

c) constant and quadratic time respectively

d) constant and logarithmic time respectively

Answer: constant and logarithmic time respectively

#### 24. Which one of the following array elements represents a binary min heap?

a) 12 10 8 25 14 17

b) 8 10 12 25 14 17

c) 25 17 14 12 10 8

d) 14 17 25 10 12 8

Answer: 8 10 12 25 14 17

a) O(n)

b) O(nlogn)

c) O(logn)

d) O(1)

a) True

b) False

#### 27. What will be the position of 5, when a max heap is constructed on the input elements 5, 70, 45, 7, 12, 15, 13, 65, 30, 25?

a) 5 will be at root

b) 5 will be at last level

c) 5 will be at second level

d) 5 can be anywhere in heap

Answer: 5 will be at last level

#### 28. Descending priority queue can be implemented using ______

a) max heap

b) min heap

c) min-max heap

d) trie

50+ Min/Max Heap MCQs with FREE PDF

a) insert

b) merge

c) delete

d) swap

a) insertion

b) merging

c) deletion

d) swapping

a) O(N)

b) O(N log N)

c) O(M log N)

d) O(log N)

a) 1

b) -1

c) 0

d) null

#### 33. Why is this heap named leftist heap?

a) only left subtrees exist

b) the tree is biased to get deep down the left

c) it is balanced

d) right trees are unbalanced

Answer: the tree is biased to get deep down the left

a) left path

b) centre path

c) right path

d) root

#### 35. What would be the result if the left subtree of the root has a null path length of 1 and the right subtree has a null path length of 2?

a) merge occurs without violation

b) violation at left subtree

c) violation at right subtree

d) violation at the root

#### 36. What happens if the null path length is not updated?

a) error occurs

b) all null path lengths will be 0

c) all null path lengths will be -1

d) all null path lengths will be 1

Answer: all null path lengths will be 0

50+ Leftlist Heap MCQs with FREE PDF

a) intersection

b) difference

c) merging

d) sorting

a) O(N)

b) O(log N)

c) O(N log N)

d) O(N2)

#### 39. Why would a recursive implementation fail in skew heaps?

a) skew heaps are self adjusting

b) efficiency gets reduced

c) lack of stack space

d) time complexity

a) Skew heaps

b) Binomial tree

c) Leftist heap

d) d-heap

a) O(N)

b) O( log N)

c) O( N log N)

d) O(N2)

a) 1

b) 2

c) 3

d) 4

a) true

b) false

a) O(N)

b) O( log N)

c) O( N log N)

d) O(N2)

#### 45. The worst case running time of all operations in a skew heap is given as?

a) O(N)

b) O(N log N)

c) O(N2)

d) O(M log N)

50+ Skew Heap MCQs with FREE PDF

a) Heapify

b) Hashing

d) Merging

#### 47. Which type of data structure is a ternary heap?

a) Array

b) Hash

c) Priority Queue

d) Priority Stack

#### 48. What is a ternary heap?

a) An array with three elements

b) Linked list with three elements

c) Tree with three children

d) Heap with all nodes having three children

Answer: Heap with all nodes having three children

#### 49. Who invented d-ary heap?

a) Carl Rick

b) Alan Turing

c) Donald Johnson

d) Euclid

#### 50. What is the time complexity for inserting a new item in a ternary heap of n elements?

a) O (log n/ log 3)

b) O (n!)

c) O (n)

d) O (1)

Answer: O (log n/ log 3)

#### 51. What is the time complexity for decreasing priority of key in a minimum ternary heap of n elements?

a) O (log n/ log 3)

b) O (n!)

c) O (n)

d) O (1)

Answer: O (log n/ log 3)

#### 52. What is the time complexity for increasing priority of key in a maximum ternary heap of n elements?

a) O (log n/ log 3)

b) O (n!)

c) O (n)

d) O (1)

Answer: O (log n/ log 3)

#### 53. What is the time complexity for deleting root key in a ternary heap of n elements?

a) O (log n/ log 3)

b) O (3log n/ log 3)

c) O (n)

d) O (1)

Answer: O (3log n/ log 3)

#### 54. What is the time complexity for increasing priority of key in a minimum ternary heap of n elements?

a) O (log n/ log 3)

b) O (3log n/ log 3)

c) O (n)

d) O (1)

Answer: O (3log n/ log 3)

50+ Ternary Heap MCQs with FREE PDF

#### 55. Which of these operations have same complexities?

a) Insertion, find_min

b) Find_min, union

c) Union, Insertion

d) Deletion, Find _max

a) True

b) False

a) n

b) n-1

c) n/2

d) logn

#### 58. Choose the option with function having same complexity for a fibonacci heap.

a) Insertion, Union

b) Insertion, Deletion

c) extract_min, insertion

d) Union, delete

#### 59. The main distinguishable characterstic of a binomial heap from a binary heap is that

a) it allows union operations very efficiently

b) it does not allow union operations that could easily be implemented in binary heap

c) the heap structure is not similar to complete binary tree

d) the location of child node is not fixed i.e child nodes could be at level (h-2) or (h-3), where h is height of heap and h>4

Answer: it allows union operations very efficiently

a) logn

b) n

c) nlogn

d) n/2

#### 61. In a binomial heap the root value is greater than left child and less than right child.

a) True

b) False

50+ Binomial and Fibonacci Heap MCQs with FREE PDF

#### 62. The total comparisons in finding both smallest and largest elements are

a) 2*n +2

b) n + ((n+1)/2) -2

c) n+logn

d) n2

a) Yes

b) No

a) h

b) h-1

c) h or h-1

d) h-2

#### 65. Choose the correct properties of weak-heap.

a) Every node has value greater than the value of child node

b) Every right child of node has greater value than parent node

c) Every left child of node has greater value than parent node

d) Every left and right child of node has same value as parent node

Answer: Every right child of node has greater value than parent node

a) True

b) False

#### 67. What is the other name of weak heap?

a) Min-heap

b) Max-heap

c) Relaxed -heap

d) Leonardo heap

50+ Weak Heap MCQs with FREE PDF

a) intersection

b) difference

c) merging

d) sorting

a) O(N)

b) O(log N)

c) O(N log N)

d) O(N2)

#### 70. Why would a recursive implementation fail in skew heaps?

a) skew heaps are self adjusting

b) efficiency gets reduced

c) lack of stack space

d) time complexity

a) Skew heaps

b) Binomial tree

c) Leftist heap

d) d-heap

a) O(N)

b) O( log N)

c) O( N log N)

d) O(N2)

a) 1

b) 2

c) 3

d) 4

a) true

b) false

#### 75. What is the amortized efficiency of skew merge?

a) O(N)

b) O( log N)

c) O( N log N)

d) O(N2)

50+ Skew Heap MCQs with FREE PDF

a) O(N)

b) O(log N)

c) O(logd N)

d) O(Nd)

a) d

b) d-1

c) d+1

d) 1

a) 1

b) 2

c) 3

d) 4

a) O(log N)

b) O(logd N)

c) O(d logd N)

d) O(d)

a) true

b) false

a) 1

b) 2

c) 3

d) 4

#### 82. On which data structure is a d-ary heap based?

a) stack

b) queue

d) priority queue