Heapsort Multiple choice Questions and Answers (MCQs)
Click on any option to know the CORRECT ANSWERS
Heap sort is an implementation of ..... using a descending priority queue.
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.
Which one of the following is false?
Heap sort is an in-place algorithm
Heap sort has O(nlogn) average case time complexity
Heap sort is stable sort
Heap sort is a comparison-based sorting algorithm
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.
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?
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.
The descending heap property is .....
A[Parent(i)] = A[i]
A[Parent(i)] <= A[i]
A[Parent(i)] >= A[i]
A[Parent(i)] > 2 * A[i]
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.
What is its wort case time complexity of Heap sort?
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.