Consider the following sorting algorithms. I. Quicksort II. Heapsort III.…

2014

Consider the following sorting algorithms. 
I. Quicksort 
II. Heapsort 
III. Mergesort 
Which of them perform in least time in the worst case?

  1. A.

    I and II only

  2. B.

    II and III only

  3. C.

    III only

  4. D.

    I, II and III

Attempted by 209 students.

Show answer & explanation

Correct answer: B

Quicksort has a worst-case time complexity of O(n²), while Heapsort and Mergesort both achieve O(n log n). Therefore, algorithms II (Heapsort) and III (Mergesort) perform in the least time in the worst case.

Explore the full course: Isro