Discussion
In which of the following cases does the worst-case time complexity of Quick Sort occur ?
Answer: C
Quick sort's worst case occurs when the pivot element is the smallest or largest element.
If the pivot is always the minimum or maximum, each partition separates only one element, so there are n levels of partitioning and the running time becomes \(O(n^2)\).
An already sorted array causes this only when the first or last element is chosen as pivot, so it is a special case of option C rather than the general condition. A randomly chosen pivot makes the worst case very unlikely.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development