Deterministic Sorting Workbench

Understand Sorting Algorithms. See How Datasets Align.

Compare comparison-based, divide-and-conquer, and non-comparison sorting algorithms with deterministic playback, live pointer tracking, and real-time complexity analysis.

Choose an Algorithm to Visualize

Launch interactive workspace with step scrubbing, live pseudocode, and state metrics.

Bubble Sort

Comparison-Based

Iteratively compares adjacent elements and swaps them if out of order until the entire list is sorted.

Worst: O(n²)Avg: O(n²)Space: O(1)
Best for: Educational instruction and verifying nearly-sorted inputs in O(n) time.

Selection Sort

Selection

Divides input into sorted and unsorted segments, repeatedly finding the minimum element to append to the sorted segment.

Worst: O(n²)Avg: O(n²)Space: O(1)
Best for: Systems where writing to flash or EEPROM is significantly more costly than reads.

Insertion Sort

Incremental

Builds sorted output one element at a time by shifting elements greater than current key to the right.

Worst: O(n²)Avg: O(n²)Space: O(1)
Best for: Small lists (n ≤ 32), online continuous data feeds, and base case in Timsort.

Merge Sort

Divide & Conquer

Recursively bisects the array, sorts each half, and merges the sorted sublists back in linear time.

Worst: O(n log n)Avg: O(n log n)Space: O(n)
Best for: External sorting of massive disk-bound files, linked lists, and guaranteed O(n log n).

Quicksort

Divide & Conquer

Selects a pivot element and partitions the array into sub-arrays of lesser and greater values.

Worst: O(n²)Avg: O(n log n)Space: O(log n)
Best for: General-purpose in-memory sorting with exceptional CPU cache locality.

Heap Sort

Tree-Based

Transforms the array into a binary max-heap in-place, then repeatedly extracts the root maximum.

Worst: O(n log n)Avg: O(n log n)Space: O(1)
Best for: Embedded microcontrollers needing guaranteed O(n log n) without memory allocation.

Counting Sort

Non-Comparison

Tabulates frequencies of distinct integer values and uses prefix sums to place items directly in order.

Worst: O(n+k)Avg: O(n+k)Space: O(k)
Best for: Dense integer distributions where key range k is comparable to or smaller than n.

Radix Sort

Non-Comparison

Processes integer digits or string keys position-by-position using stable counting sort passes.

Worst: O(nk)Avg: O(nk)Space: O(n+k)
Best for: Fixed-width numeric identifiers, IP addresses, and building suffix arrays.

Bucket Sort

Distribution

Distributes elements into uniformly spaced buckets, sorts each bucket, and concatenates results.

Worst: O(n²)Avg: O(n)Space: O(n+k)
Best for: Floating-point values uniformly distributed over a known real-number range.

Shell Sort

Diminishing Stride

Sorts distant pairs using a diminishing gap sequence, accelerating final insertion passes.

Worst: O(n²)Avg: O(n^(4/3))Space: O(1)
Best for: Embedded systems with strict stack constraints and medium datasets.

TimSort

Adaptive Hybrid

Combines merge sort and binary insertion sort to exploit natural ordered runs in real-world data.

Worst: O(n log n)Avg: O(n log n)Space: O(n)
Best for: Standard library default in Python, Java, Android, and V8 JavaScript.

Comb Sort

Turtle Elimination

Shrinks gap by 1.3 each pass to rapidly eliminate small values trapped near the end of the array.

Worst: O(n²)Avg: O(n log n)Space: O(1)
Best for: Fast in-place sorting without recursion overhead.

Cocktail Shaker Sort

Bidirectional Bubble

Alternates forward and backward bubbling passes with contracting boundaries from both ends.

Worst: O(n²)Avg: O(n²)Space: O(1)
Best for: Nearly sorted arrays with misplaced elements near both ends.

Gnome Sort

Single Pointer

Single-pointer sort stepping forward on ordered items and swapping backward on inversions.

Worst: O(n²)Avg: O(n²)Space: O(1)
Best for: Tiny microcontrollers with extremely limited program ROM space.

Cycle Sort

Write-Optimal

Theoretically minimizes memory writes (≤ n-1 writes) by rotating elements along permutation cycles.

Worst: O(n²)Avg: O(n²)Space: O(1)
Best for: Flash memory and EEPROM where write cycles physically degrade memory longevity.

Pigeonhole Sort

Slot Distribution

Assigns elements to discrete range-indexed pigeonholes followed by linear sequential collection.

Worst: O(n+range)Avg: O(n+range)Space: O(range)
Best for: Dense integer data where key range is roughly comparable to array length.

Tree Sort

BST In-Order

Inserts elements into a Binary Search Tree and performs an in-order traversal to emit sorted keys.

Worst: O(n²)Avg: O(n log n)Space: O(n)
Best for: Streaming feeds requiring simultaneous dynamic search indexing and sorted emission.

Strand Sort

Strand Merge

Repeatedly pulls greedy non-decreasing sub-lists from an unsorted pool and merges them into sorted output.

Worst: O(n²)Avg: O(n²)Space: O(n)
Best for: Naturally suited for linked lists due to O(1) pointer splicing.

Pancake Sort

Prefix Reversal

Sorts strictly through prefix reversals ("spatula flips") within at most 2n - 3 operations.

Worst: O(n²)Avg: O(n²)Space: O(1)
Best for: Combinatorial prefix mathematics and genome synteny block reversal analysis.

Stooge Sort

Overlapping 2/3

Recursive algorithm sorting first 2/3, last 2/3, and first 2/3 overlapping partitions with O(n^2.71) time.

Worst: O(n^2.71)Avg: O(n^2.71)Space: O(log n)
Best for: Theoretical computer science education illustrating Master Theorem recursion bounds.

Introsort

Triple Hybrid

Begins with Quick Sort, falls back to Heap Sort when depth exceeds 2*floor(log2(n)), and uses Insertion Sort for small slices.

Worst: O(n log n)Avg: O(n log n)Space: O(log n)
Best for: C++ std::sort in libstdc++ and modern high-throughput system runtimes.