50 SEARCHING AND SELECTION ALGORITHMS
means that we can determine the total number of comparisons done for every
possible case by adding, for every level, the product of the number of nodes on
each level and the number of comparisons for that level. This gives an average
case of analysis ofWe can use Equation 1.19 to simplify this equation toBecauseN = 2k 1, 2k = N + 1.AsN gets larger, k/N becomes zero, givingAN() N----^1 i 2 i–1 forN
i=1k
∑^2
==k– 1AN() N----^1 *^12 -- i 2 i
i=1k
= ∑AN()= N----^1 *^12 -- * []()k– 1 2 k+1+ 2AN()= N----^1 []()k– 1 2 k+ 1AN()= N----^1 []k 2 k– 2 k+ 1AN() k^2
[]k–() 2 k– 1
N= ---------------------------------------AN() k^2
[]k–N
N= -------------------------AN() k^2k
= ---------N-– 1AN() kN()+^1
N= ---------------------– 1AN()kNk* +
= ----------------------N – 1AN()≈k– 1
AN()≈lg()N+ 1 – 1forN = 2 k– 1
forN = 2 k– 1