# Min/Max Heap Multiple choice Questions and Answers (MCQs)

## Min/Max Heap Multiple choice Questions and Answers (MCQs)

 Question 1 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Descending priority queue can be implemented using .....
 A max heap B min heap C min-max heap D trie
Question 1 Explanation:
Descending priority queue arranges the elements based on their priority or value and allows removing the elements in descending order. So, it can be efficiently implemented using max heap.

 Question 2 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Min heap can be used to implement selection sort.
 A True B False
Question 2 Explanation:
In min heap, the insertion and deletion operation takes O(logn) time. Therefore, a selection sort with n insertions and n deletions can be implemented using a min heap in O(nlogn) operations.

 Question 3 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The procedure given below is used to maintain min-order in the min heap. Find out the missing statements, represented as X.

`procedure TrickleDownMin(i) 	 if A[i] has children then 		m := index of smallest of the children 		 or grandchildren (if any) of A[i] 		if A[m] is a grandchild of A[i] then 			 if A[m] < A[i] then 				swap A[i] and A[m] 				X: ..... 					..... 			 endif 	 			TrickleDownMin(m) 		 endif 		else //{A[m] is a child of A[i]}  			if A[m] < A[i] then 				swap A[i] and A[m] 		endif 	 endif`
 A if A[m] > A[parent(m)] then swap A[m] and A[parent(m)] B if A[m] > A[parent(m)] then swap A[i] and A[parent(m)] C if A[m] < A[parent(m)] then swap A[m] and A[parent(m)] D if A[m] > A[parent(m)] then swap A[i] and A[parent(m)]
Question 3 Explanation:
In TrickleDownMin() procedure, we maintain the min-ordering of the min heap. In this procedure, we locate the lowest child or grandchild of the element at positions i. If the lowest element is grandchild then we check that it is smaller than both, its parent and A[i].

 Question 4 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
The ascending heap property is .....
 A A[Parent(i)] =A[i] B A[Parent(i)] <= A[i] C A[Parent(i)] >= A[i] D A[Parent(i)] > 2 * A[i]
Question 4 Explanation:
The min heap is also known as ascending heap. Min heap of size n is an almost complete binary tree of n nodes such that the element at each node is greater than or equal to the element at its parent node.

 Question 5 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
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
Question 5 Explanation:
In the min heap, the root is the maximum element in the tree. So, locating it takes constant time, but deleting it takes logarithmic time. Because after deleting it, the root is replaced with last element and then the procedure to maintain the min ordering is invoked.

There are 5 questions to complete.