- 1 current stop: learning
- 2 upcoming
- 3 upcoming
- 4 upcoming
- 5 upcoming
Finish after stop 5
Stop 1 of 5 · Pharmacy cart: shelving by expiry
Trick to keep in mind+3 XP
Selection sort is blind to order: it always scans everything left.
To place the smallest remaining item, selection sort has to look at every remaining item, even if the cart is already in order. With 5 items that is 4 + 3 + 2 + 1 = 10 looks, and the pattern is n(n-1)/2 for n items. An algorithm that notices existing order can finish earlier; this one cannot.
Read it once, then a question tests whether the trick stuck.