← Back to Index

Sorting Efficiency

Chapter 16: Algorithms

An algorithm is a step-by-step procedure for calculation. The efficiency of an algorithm is measured by how its runtime grows with input size ($n$).

Bubble Sort [$O(n^2)$]: Simple repeatedly swaps adjacent elements if they are in wrong order.
Quick Sort [$O(n \log n)$]: Comparison sort using divide and conquer. Puts "pivot" in right place.

Instructions: Select an algorithm and run it. Observe the number of comparisons and swaps.

Algorithm: None
Comparisons: 0
Swaps: 0
Speed:
Previous Chapter 15: Combinatorics