Sorting Algorithms
Everything on SkillVeris tagged Sorting Algorithms — collected across the glossary, study notes, blog, and cheat sheets.
16 resources across 2 libraries
Cheat Sheets(1)
Interview Questions(15)
Merge Sort vs Quick Sort: What is the Difference?
Merge sort splits an array in half, recursively sorts both halves, then merges them, guaranteeing O(n log n) time and stability at the cost of O(n) extra space…
What is Heap Sort?
Heap sort builds a max-heap from the input array, then repeatedly swaps the root (the current maximum) with the last unsorted element and sifts the reduced hea…
What is Counting Sort?
Counting sort sorts integers by counting how many times each distinct value occurs, converting those counts into prefix sums that give each value its final pos…
What is Radix Sort?
Radix sort sorts integers (or fixed-length strings) by repeatedly applying a stable sort, usually counting sort, on one digit position at a time, moving from t…
What is Bucket Sort?
Bucket sort distributes elements from a roughly uniformly distributed input into a fixed number of buckets by value range, sorts each bucket individually with…
What is Insertion Sort?
Insertion sort builds the final sorted array one element at a time by taking each new element and shifting it leftward past every larger already-sorted element…
What is Selection Sort?
Selection sort repeatedly scans the unsorted portion of an array to find the minimum element and swaps it into place at the front, giving an O(n²) comparison-b…
What is Shell Sort?
Shell sort is an in-place comparison sort that generalizes insertion sort by first comparing and swapping elements far apart using a shrinking gap sequence, mo…
What is Timsort?
Timsort is a hybrid, stable sorting algorithm — the default in Python’s sort() and sorted() and in Java’s Arrays.sort() for objects — that finds naturally occu…
What is Bubble Sort?
Bubble sort repeatedly steps through an array comparing each pair of adjacent elements and swapping them if they are out of order, so on every full pass the la…
Stable vs Unstable Sort: What is the Difference?
A stable sort preserves the original relative order of elements that compare as equal on the sort key, while an unstable sort makes no such guarantee and may r…
How Do You Find the Kth Largest Element in an Array?
The kth largest element can be found in average O(n) time using quickselect, a partition-based algorithm derived from quicksort that only recurses into the sid…
How Do You Solve the Three Sum Problem?
Sort the array, fix one element at a time, then use a two-pointer sweep on the remaining subarray to find pairs that sum to the negative of the fixed element,…
How Do You Solve the Four Sum Problem?
Sort the array, then use two nested loops to fix the first two elements and a two-pointer sweep on the remainder to find pairs completing the target sum, givin…
What is External Sorting?
External sorting is a family of algorithms for sorting data too large to fit in main memory, most commonly external merge sort: split the data into memory-size…