Growth Rate and the Common Families
Solution
Examples: swap or reading an element by index is ; binary search is ; linear search is ; the fastest general-purpose sorts are ; selection sort is .
Solution
The first three are all . The fourth is .
, , and differ by a constant factor, and that factor is the same at every . The gap between and keeps growing as grows, with no bound. Big-Oh keeps the growth rate and drops the constant because the growth rate is what decides which algorithm does less work on large inputs.
Solution
is faster for large , because grows more slowly than .
does less work while , that is, for every below . At the two tie, and for every larger , does less work.
Solution
The answer is (B).
Imagine is binary search and is linear search. is logarithmic and as grows, grows more slowly than . So ’s runtime grows more slowly than ’s. The algorithm in the slower-growing family does less work as gets large, so finishes sooner; it is the faster algorithm.