ArraysLesson 8Free preview
DSA Quick Sort
This lesson is part of DSA · All levels
Summary
Quick sort selects an element as a pivot, then divides the list into two parts: the smaller element of the pivot and the larger or equal element. The pivot is then placed in the final position and the process continues recursively on both sides. The average complexity is fast, but the worst case can be P1 when the partition is always unbalanced.
Key points
- Strategy of divide and conquer by partitioning
- The choice of pivot influences performance, such as the middle or random element
- Average O(n log n), worst O(n^2) on an unbalanced partition
- In-place with recursion on both sides of the partition
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.