Question 12Asked in DSSSB TGT Computer Science (Technical), 8 Aug 2021, Shift 2

What is the worst case running time of quick sort algorithm?

  1. Aθ(x)
  2. Bθ(x²)
  3. Cθ(x log₂x)
  4. Dθ(x log₂x²)
Show answerHide answer

Correct answer: (B) θ(x²)

Explanation

Quick sort's worst case happens when the pivot is always the smallest or largest element, for example on already sorted input. Each partition then removes only one element, giving Θ(n²).

From DSSSB TGT Computer Science PYQ (Technical), 8 Aug 2021, Shift 2

This is question 12 of DSSSB TGT Computer Science PYQ (Technical), 8 Aug 2021, Shift 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.