Loading page…
A cinema app sorts a hundred thousand seat holds that are almost in order. Selection sort makes nearly five billion comparisons, about eighty three minutes. Insertion sort stops each scan early and needs about two hundred twenty five thousand. The lesson writes both sorts, counts their comparisons, swaps and shifts on real inputs, and shows when each is the right choice: nearly sorted data, expensive writes, stable order. It also shows when a simple sort is the wrong tool, on a long random list.
You work on the cinema app of a theatre chain.