Sorting Algorithms Visualizer

Simple Sorting Algorithms

Bubble Sort

Compare adjacent elements and swap if out of order.

Best

O(n)

Average

O(n²)

Worst

O(n²)

Selection Sort

Find the smallest element and place it in the correct position.

Best

O(n²)

Average

O(n²)

Worst

O(n²)

Insertion Sort

Insert each element into its correct position in the sorted part.

Best

O(n)

Average

O(n²)

Worst

O(n²)

Efficient Sorting Algorithms

Merge Sort

Divide and conquer approach; recursively split and merge sorted subarrays.

Best

O(n log n)

Average

O(n log n)

Worst

O(n log n)

Quick Sort

Divide and conquer; select a pivot, partition, and recursively sort subarrays.

Best

O(n log n)

Average

O(n log n)

Worst

O(n²)

Heap Sort

Uses a heap data structure to repeatedly extract the maximum/minimum element.

Best

O(n log n)

Average

O(n log n)

Worst

O(n log n)

Advanced Comparison-Based Algorithms

Tim Sort

Hybrid of merge and insertion sort; optimized for real-world data.

Best

O(n)

Average

O(n log n)

Worst

O(n log n)

Intro Sort

Hybrid of quick sort and heap sort; switches to heap sort in worst-case scenarios.

Best

O(n log n)

Average

O(n log n)

Worst

O(n log n)