Discussion
What is the time complexity of the Quick Sort algorithm in the average case ?
Answer: B
Quick sort's average case is O(n log n).
Each partition step does linear work. With reasonably balanced splits the recursion is about log n levels deep, giving n log n in total, and averaged over random inputs or random pivots the expected number of comparisons is about 1.39 n log2 n.
\(O(n^{2})\) is quick sort's worst case, when the pivot is always the smallest or largest element, for example on sorted input with a first-element pivot. O(n) is too fast for any comparison sort, and O(log n) is the depth of the recursion, not the total work.
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