ALGOHAY

⚖️ Algorithm Comparison Tool

Choose the algorithms you want to weigh up, set an input size, and rank them by best-, average-, or worst-case operation count — with time, space, and stability side by side in one table.

📊 Compare & Rank Algorithms

⚖️ Ranked by average case at n = 1,000 (fastest first)

#AlgorithmBestAverageWorstSpaceStable~Ops (average)
1Merge SortO(n log n)O(n log n)O(n log n)O(n)Yes9965.78
2Quick SortO(n log n)O(n log n)O(n²)O(log n)No9965.78
3Heap SortO(n log n)O(n log n)O(n log n)O(1)No9965.78
4Bubble SortO(n)O(n²)O(n²)O(1)Yes1,000,000

What is the Algorithm Comparison Tool?

It is a reference table you can drive. Instead of memorising the complexity grid for the classic sorting, searching, and graph algorithms, you select the ones you care about and read their best, average, and worst-case time, their space, and their stability in one place — then rank them by representative operation count at a specific input size and case.

Use it to choose the right algorithm for a workload, to revise the trade-offs before an interview, or to demonstrate why the worst case matters — flip to worst-case ranking and watch Quick sort fall behind Merge and Heap sort, or bump the input size and see Linear search overtaken by Binary search. It is a curated, deterministic comparison, not a benchmark of any particular implementation.

❓ Frequently Asked Questions

Which algorithms can I compare?

A curated built-in set: the sorting algorithms Bubble, Merge, Quick, and Heap sort; the search algorithms Linear and Binary search; and the graph traversals Breadth-First Search and Depth-First Search. Each carries its best, average, and worst-case time, its auxiliary space, and whether a sort is stable.

What does 'stable' mean for a sort?

A stable sort preserves the relative order of elements that compare equal. Merge sort and Bubble sort are stable; Quick sort and Heap sort are not, in their usual in-place forms. Stability matters when you sort by one key after already sorting by another and want to keep the earlier ordering as a tiebreaker.

How are the operation counts calculated?

They are representative values of each algorithm's complexity at the input size you choose — for example Merge sort's average case is evaluated as n·log₂n and Bubble sort's as n². They compare the shape and relative cost of the algorithms rather than predicting exact instruction counts, which depend on constants that Big O hides.

Why does Quick sort beat Merge sort in practice despite the same average complexity?

Both are O(n log n) on average, but Quick sort typically has smaller constant factors and better cache behaviour, so it often runs faster in practice — at the cost of an O(n²) worst case and no stability. Switch the case selector to Worst here to see Quick sort's quadratic blow-up while Merge and Heap sort stay O(n log n).