March 2009
Intermediate to advanced
832 pages
23h 49m
English
Many of you probably have a change jar somewhere—a container full of coins. From time to time, you might dig into your change jar to find a quarter,[1] and the process of doing so is probably second nature. Partly because it’s so familiar, the process of retrieving a quarter from a change jar will be a useful example for the discussion of algorithms and complexity. While a coin isn’t exactly data, retrieving a quarter is much like executing this T-SQL SELECT query:
SELECT TOP (1) Coin FROM ChangeJar WHERE Denomination = 0.25 ORDER BY (SELECT NULL);
I’m sure you know more than one algorithm for executing this task—to retrieve a quarter from a coin jar. Most of the time, you look into ...