๐ฎ Sorting (Practice)
Companion to the Sorting Algorithms guide. Watch bubble sort settle elements one by one, then implement insertion sort yourself.
๐ฌ Watch it workโ
Bubble Sort โ adjacent compare & swapStep 1 / 23
Unsorted. Bubble sort compares adjacent pairs and swaps if out of order.
๐ Your turnโ
Loading editorโฆ
๐ง Challenge yourselfโ
- Modify it to sort in descending order.
- Count the number of swaps โ which input order maximizes them?
- Why is insertion sort O(n) on an already-sorted array but O(nยฒ) worst case?
Continue the path โ Stacks & Queues