Question discussion

The average-case time complexity of the Quickselect algorithm, used to find the k-th smallest element of an unsorted array of n elements, is

2538Medium DSSSB TGT Computer Science 0 replies

The average-case time complexity of the Quickselect algorithm, used to find the k-th smallest element of an unsorted array of n elements, is

  • AO(log n)
  • BO(n log n)
  • CO(n)
  • DO(n²)
Correct answer: C

Explanation

Quickselect partitions the array like quicksort but continues in only one part, so the expected work is n + n/2 + n/4 + … = O(n), although the worst case is O(n²).

Discussion 0

Nobody has replied yet. Start the discussion!