Guided Notes

Simple Sorting: Bubble, Selection & Insertion

Three O(n²) sorting algorithms — how each works, step by step, and when they're useful.

Why study sorting?

Slide 1 / 5

Sorting puts values in order, and many other algorithms depend on it: binary search needs sorted data, duplicates are easy to find in a sorted list, and results are easier to read.

In real code you'd call a built-in sort (Python's sorted() is an optimized O(n log n) algorithm called Timsort). Learning to write sorting algorithms teaches loops, swaps, invariants, and complexity — skills that transfer to every other algorithm.

← Arrays & Time Complexity