Quicksort
Quicksort is a comparison-based sorting algorithm that partitions elements around a pivot and recursively sorts the resulting partitions.
Grokking Algorithms, Second Edition
Quicksort is a comparison-based sorting algorithm that partitions a sequence around a pivot and recursively sorts the partitions.
- How it is used
- Uses quicksort to demonstrate divide and conquer through a practical sorting algorithm.
- How deep it goes
- Works through partitioning, a recursive Python implementation, and pivot-dependent running time and stack depth.
- Examples
- Sorts a three-element array, implements quicksort in Python, and contrasts pivot choices on an already sorted array.
- What you can do after
- Build it from scratch for an array and choose a random pivot for O(n log n) average running time.
Read how Grokking Algorithms, Second Edition explains quicksort →
Software Design for Python Programmers
Quicksort is a comparison-sorting algorithm that selects a pivot, partitions values around it, and recursively sorts the resulting sublists.
- How it is used
- Uses recursion to sort lists efficiently for ordered output and searchable records.
- How deep it goes
- Descends through pivot partitioning, index movement, swaps, base cases, recursive calls, and a complete Python implementation.
- Examples
- Demonstrates pivot 7 in a sorting trace, pivot 52 during partitioning, and twenty randomly generated Python values.
- What you can do after
- Build it from scratch as an in-place Python sorter with recursive partitioning and sortedness verification.
Read how Software Design for Python Programmers explains quicksort →
Object-Oriented Software Design in C++
Quicksort is a divide-and-conquer sorting algorithm that partitions an array around a pivot and recursively sorts the resulting subarrays.
- How it is used
- Uses recursion to rapidly sort arrays by reducing one problem to independently sortable subarrays.
- How deep it goes
- Descends from algorithm steps through index-level partitioning and C++ member functions, without discussing alternative pivot strategies.
- Examples
- Demonstrates pivot traces, partition swaps, recursive subarrays, and a random twenty-element C++ test array.
- What you can do after
- Build it from scratch using recursive sort, partition, swapping, verification, and array-printing functions.
Read how Object-Oriented Software Design in C++ explains quicksort →
Also covered in
What to know first
- recursionRecursion is a computational technique in which a definition or procedure refers to or invokes itself, directly or indirectly.
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- machine learningMachine learning is a field of computational methods in which systems learn patterns or relationships from data to make predictions, decisions, or other outputs.
Related concepts
- pivotuses · In partitioning, a pivot is a selected element or value that serves as a comparison boundary for dividing other elements into groups.
- dataset splituses · A dataset split is the division of a dataset into distinct subsets assigned different purposes, such as training, validation, or evaluation.
- machine learningkind of · Machine learning is a field of computational methods in which systems learn patterns or relationships from data to make predictions, decisions, or other outputs.
- recursionuses · Recursion is a computational technique in which a definition or procedure refers to or invokes itself, directly or indirectly.
- sorting algorithmkind of · A sorting algorithm is a procedure that rearranges elements of a collection into an order determined by an ordering criterion.
- divide-and-conquer approachuses · Divide and conquer is a problem-solving strategy that decomposes a problem into smaller subproblems, solves them separately, and combines or completes their results.
Questions about quicksort
What is quicksort?
Quicksort is a comparison-based sorting algorithm that partitions elements around a pivot and recursively sorts the resulting partitions.
Which Manning books explain quicksort?
Grokking Algorithms, Second Edition, Software Design for Python Programmers and Object-Oriented Software Design in C++.
What should I know before learning quicksort?
Manning books that teach quicksort usually introduce recursion, array and machine learning first.
What is quicksort a kind of?
Quicksort is a kind of machine learning. Machine learning is a field of computational methods in which systems learn patterns or relationships from data to make predictions, decisions, or other outputs.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


