Ch 7 · Sorting — Putting Things in Order · Data Structures & Algorithms

Topic 7 of 10 in Data Structures & Algorithms — Foundations — 2 lessons.

Bubble Sort (To Understand, Not To Use)

Bubble sort repeatedly walks the list, swapping any two neighbours that are out of order, until no swaps are needed. It is easy to picture but O(n²) — great for learning how sorting works, not for real data.

The Sorts You Actually Use

The fast, real-world sorts — merge sort and quicksort — are O(n log n) by splitting the list in half, sorting each half, and combining. You will build merge sort in the intermediate track. In practice, Python's built-in sorted() (an optimised hybrid called Timsort) is what you reach for.

All topics in Data Structures & Algorithms Beginner

  1. Thinking Like a Computer Scientist
  2. Arrays & Lists — The Workhorse
  3. Stacks — Last In, First Out
  4. Queues — First In, First Out
  5. Linked Lists — Nodes on a Chain
  6. Searching — Finding the Needle
  7. Sorting — Putting Things in Order
  8. Recursion — Functions That Call Themselves
  9. Hash Tables — Instant Lookups
  10. Mini-Projects & Practice