Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Quick Sort Lab
Sorting
Problem shape
Intermediate
4
8
15
16
23
42
Core idea
Partition values around a pivot, then recursively sort both sides.
Step 1 / 5
Problem shape
Sorting Intermediate
Quick Sort
Welcome to the Quick Sort algorithm lab. Partition values around a pivot, then recursively sort both sides. Use it when: Use for fast in-place general sorting with good pivot selection. The time complexity is Average O(n log n), worst O(n^2), and the space complexity is O(log n). The pseudocode is: quick(left, right) if left >= right return pivot = partition(left, right) quick(left, pivot - 1) quick(pivot + 1, right) As you practice, track the state that changes and the condition that makes the algorithm stop.
Time
Average O(n log n), worst O(n^2)
Space
O(log n)
Pseudocode
quick(left, right)
if left >= right return
pivot = partition(left, right)
quick(left, pivot - 1)
quick(pivot + 1, right) 1.0x