Single Choice Easy

QWhat is the time complexity of a quicksort algorithm for sorting an array of n elements in the worst case?

ID: #15266 Time Complexity 176 views
Question Info
#15266Q ID
EasyDifficulty
Time ComplexityTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A O(1)
  • B O(log n)
  • C O(n)
  • D O(n^2)
Correct Answer

Explanation

Quicksort is a comparison-based sorting algorithm that divides the array into two subarrays based on a pivot element, recursively sorts the subarrays, and combines them. In the worst case, if the pivot selection consistently results in unbalanced partitions, quicksort degrades to its quadratic time complexity. This occurs when the pivot is always the minimum or maximum element, leading to n recursive calls and resulting in a time complexity of O(n^2).

Share This Question

Challenge a friend or share with your study group.