ALGORITHMS / BEGINNER

Sorting Lab

Step through three foundational sorting algorithms and watch the array, variables, and C++ code move together.

SELECTION SORT

Find the smallest, then place it.

Live trace

What the computer is doing

C++ implementation

Tip: use the Left and Right arrow keys to move through the trace.

QUICK COMPARISON

Which approach fits?

Selection

Does few swaps. Useful when writing is costly.

Time: O(n^2)

Bubble

Simple neighbour comparisons. Great for learning swaps.

Time: O(n^2)

Insertion

Efficient for small or nearly sorted lists.

Best case: O(n)