• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on HeapSort Algorithm with Answers

Question 1

Suppose we are sorting an array of eight integers using heapsort, and we have just finished some heapify (either maxheapify or minheapify) operations. The array now looks like this: 16 14 15 10 12 27 28 How many heapify operations have been performed on root of heap?

  • 1

  • 2

  • 3 or 4

  • 5 or 6

Question 2

Consider a binary min heap containing n elements and every node is having degree 2 ( i.e. full binary min heap tree). What is the probability of finding the largest element at the last level ?
  • 1/2
  • 1
  • 1/n
  • 1/2^n

Question 3

Which of the following sorting algorithms in its typical implementation gives best performance when applied on an array which is sorted or almost sorted (maximum 1 or two elements are misplaced).

  • Quick Sort

  • Heap Sort

  • Merge Sort

  • Insertion Sort

Question 4

The number of elements that can be sorted in [Tex]\\Theta(logn)[/Tex] time using heap sort is
(A) [Tex]\\Theta(1)[/Tex]
(B) [Tex]\\Theta(\\sqrt{logn})[/Tex]
(C) [Tex]\\Theta(Log n/(Log Log n))[/Tex]
(d) [Tex]\\Theta(Log n)[/Tex] 
  • A
  • B
  • C
  • D

Question 5

Given an unsorted array. The array has this property that every element in the array is at most k distance from its position in a sorted array where k is a positive integer smaller than the size of an array. Which sorting algorithm can be easily modified for sorting this array and what is the obtainable time complexity?

  • Insertion Sort with time complexity O(kn)

  • Heap Sort with time complexity O(nLogk)

  • Quick Sort with time complexity O(kLogk)

  • Merge Sort with time complexity O(kLogk)

Question 6

You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?
  • Heap sort
  • Merge sort
  • Quick sort
  • Insertion sort

Question 7

Which sorting algorithms is most efficient to sort string consisting of ASCII characters?
  • Quick sort
  • Heap sort
  • Merge sort
  • Counting sort

Question 8

Which of the following is true about merge sort?

  • Merge Sort works better than quick sort if data is accessed from slow sequential memory.

  • Merge Sort is stable sort by nature

  • Merge sort outperforms heap sort in most of the practical situations.

  • All of the above.

Question 9

Which of the following is not true about comparison-based sorting algorithms?

  • The minimum possible time complexity of a comparison-based sorting algorithm is O(n(log(n)) for a random input array

  • Any comparison based sorting algorithm can be made stable by using position as a criteria when two elements are compared

  • Counting Sort is not a comparison based sorting algorithm

  • Heap Sort is not a comparison based sorting algorithm.

There are 9 questions to complete.

Last Updated :
Take a part in the ongoing discussion