Data Structures and Algorithms ยท Searching and sorting
Elementary comparison sorts
The simple O(n squared) sorts, bubble, insertion, selection, that compare and swap pairs of elements.
Also known as: bubble sort, insertion sort, selection sort.
Start a lesson on Elementary comparison sortsLearn first
- Arrays: A fixed-layout, contiguous block of memory where any index is reached in constant time.
Leads to
- Divide-and-conquer sorting: Divide-and-conquer sorts, merge sort and quicksort, that beat O(n squared) by splitting the problem.
- Non-comparison sorting: Sorting by exploiting known structure in the values themselves, counting or radix, instead of comparisons.
Related topics