πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!

  • google app store apple app store
  • βœ–

      Question

      Quick Sort, another Divide and Conquer algorithm,

      partitions an array around a pivot. The choice of pivot can significantly impact its performance. What is its worst-case time complexity?
      A O(N log N) Correct Answer Incorrect Answer
      B O(log N) Correct Answer Incorrect Answer
      C O(N) Correct Answer Incorrect Answer
      D O(NΒ²) Correct Answer Incorrect Answer
      E O(1) Correct Answer Incorrect Answer

      Solution

      In the worst case for Quick Sort, the pivot selection consistently results in highly unbalanced partitions (e.g., always picking the smallest or largest element as the pivot). This leads to one subproblem of size N-1 and another of size 0, effectively degenerating into a selection sort-like behavior, resulting in O(NΒ²) time complexity.

      Practice Next
      ask-question