• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Top MCQs on Sorting Algorithms with Answers

Question 21

In quick sort, for sorting n elements, the (n/4)th smallest element is selected as a pivot using an O(n) time algorithm. What is the worst-case time complexity of the quick sort?

(A) θ(n)

(B) θ(n*log(n))

(C) θ(n^2)

(D) θ(n^2 log n)

  • A

  • B

  • C

  • D

Question 22

Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub-lists each of which contains at least one-fifth of the elements. Let T(n) be the number of comparisons required to sort n elements. Then

  • T(n) <= 2T(n/5) + n

  • T(n) <= T(n/5) + T(4n/5) + n

  • T(n) <= 2T(4n/5) + n

  • T(n) <= 2T(n/2) + n

Question 23

Let P be a QuickSort Program to sort numbers in ascending order using the first element as pivot. Let t1 and t2 be the number of comparisons made by P for the inputs {1, 2, 3, 4, 5} and {4, 1, 5, 3, 2} respectively. Which one of the following holds?

  • t1 = 5

  • t1 < t2

  • t1 > t2

  • t1 = t2

Question 24

You have an array of n elements. Suppose you implement quick sort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the worst case performance is

  • O(n2)

  • O(n*log(n))

  • Theta(n*log(n))

  • O(n3)

Question 25

In a permutation a1.....an of n distinct integers, an inversion is a pair (ai, aj) such that i < j and ai > aj. What would be the worst-case time complexity of the Insertion Sort algorithm, if the inputs are restricted to permutations of 1.....n with at most n inversions?

  • Θ (n2)

  • Θ (n*log(n))

  • Θ (n1.5)

  • Θ (n)

Question 26

Randomized quicksort is an extension of quicksort where the pivot is chosen randomly. What is the worst case complexity of sorting n numbers using randomized quicksort?

  • O(n)

  • O(n*log(n))

  • O(n2)

  • O(n!)

Question 27

Which of the following changes to typical QuickSort improves its performance on average and are generally done in practice.

1) Randomly picking up to make worst case less 
   likely to occur.
2) Calling insertion sort for small sized arrays 
   to reduce recursive calls.
3) QuickSort is tail recursive, so tail call 
   optimizations can be done.
4) A linear time median searching algorithm is used 
   to pick the median, so that the worst case time 
   reduces to O(nLogn)
  • 1 and 2

  • 2, 3, and 4

  • 1, 2 and 3

  • 2, 3 and 4

Question 28

Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n(≥ 2) numbers? In the recurrence equations given in the options below, c is a constant.

  • T(n) = 2T (n/2) + cn

  • T(n) = T(n – 1) + T(0) + cn

  • T(n) = 2T (n – 2) + cn

  • T(n) = T(n/2) + cn

Question 29

Assume that a mergesort algorithm in the worst case takes 30 seconds for an input of size 64. Which of the following most closely approximates the maximum input size of a problem that can be solved in 6 minutes?
  • 256
  • 512
  • 1024
  • 2048

Question 30

The worst case running times of Insertion sort, Merge sort and Quick sort, respectively, are:

  • Θ(n log n), Θ(n log n) and Θ(n2)

  • Θ(n2), Θ(n2) and Θ(n Log n)

  • Θ(n2), Θ(n log n) and Θ(n log n)

  • Θ(n2), Θ(n log n) and Θ(n2)

There are 61 questions to complete.

Last Updated :
Take a part in the ongoing discussion