Heapsort Multiple choice Questions and Answers (MCQs)

 

 Buy/Download all MCQ Ebook   >>>Click Here<<<

Heapsort Multiple choice Questions and Answers (MCQs)

Click on any option to know the CORRECT ANSWERS

Question 1
Heap sort is an implementation of ..... using a descending priority queue.
A
insertion sort
B
selection sort
C
bubble sort
D
merge sort
Arab culture Questions answers

Question 1 Explanation: 
Heap sort is an implementation of selection sort using the input array as a heap representing a descending priority queue. Heap sort algorithm is divided into two phase. In first phase the max-heap is created and the second phase (selection phase) deletes the elements from the priority queue using siftdown operation.

Question 2
Which one of the following is false?
A
Heap sort is an in-place algorithm
B
Heap sort has O(nlogn) average case time complexity
C
Heap sort is stable sort
D
Heap sort is a comparison-based sorting algorithm
Reading comprehension Questions answers

Question 2 Explanation: 
Heap sort is a comparison based sorting algorithm and has time complexity O(nlogn) in the average case. Heap sort is an in-place algorithm as it needs O(1) of auxiliary space. Heap sort uses heap and operations on heap can change the relative order of items with the same key values. Therefore, Heap sort is not a stable sort.

Question 3
The essential part of Heap sort is construction of max-heap. Consider the tree shown below, the node 24 violates the max-heap property. Once heapify procedure is applied to it, which position will it be in?
A
4
B
5
C
8
D
9
UPSC Questions answers

Question 3 Explanation: 
In max-heap element at each node is smaller than or equal to the element at its parent node. On applying the heapify procedure on item at position 2, it will be in position 9 as shown below.

Question 4
The descending 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]
Data interpretation (DI) Questions answers

Question 4 Explanation: 
The max-heap is also known as descending heap. Max-heap of size n is an almost complete binary tree of n nodes such that the element at each node is less than or equal to the element at its parent node.

Question 5
What is its wort case time complexity of Heap sort?
A
O(nlogn)
B
O(n2logn)
C
O(n2)
D
O(n3)
KBC Questions answers

Question 5 Explanation: 
In Heap sort, the call to procedure build....Max-heap takes O(n) time and each of O(n) calls to the function max....Heapify takes O(logn) time. So the worst case complexity of Heap sort is O(nlogn).

There are 5 questions to complete.

 

 Buy/Download all MCQ Ebook >>>CLICK HERE<<<