11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

498 Chap. 15 Lower BoundsThis recurrence (<strong>and</strong> the corresponding algorithm) yields T(n) = ⌈3n/2⌉ − 2comparisons. Is this optimal? We now introduce yet another tool to our collectionof lower bounds proof techniques: The st<strong>at</strong>e space proof.We will model our algorithm by defining a st<strong>at</strong>e th<strong>at</strong> the algorithm must be in <strong>at</strong>any given instant. We can then define the start st<strong>at</strong>e, the end st<strong>at</strong>e, <strong>and</strong> the transitionsbetween st<strong>at</strong>es th<strong>at</strong> any algorithm can support. From this, we will reason about theminimum number of st<strong>at</strong>es th<strong>at</strong> the algorithm must go through to get from the startto the end, to reach a st<strong>at</strong>e space lower bound.At any given instant, we can track the following four c<strong>at</strong>egories of elements:• Untested: Elements th<strong>at</strong> have not been tested.• Winners: Elements th<strong>at</strong> have won <strong>at</strong> least once, <strong>and</strong> never lost.• Losers: Elements th<strong>at</strong> have lost <strong>at</strong> least once, <strong>and</strong> never won.• Middle: Elements th<strong>at</strong> have both won <strong>and</strong> lost <strong>at</strong> least once.We define the current st<strong>at</strong>e to be a vector of four values, (U, W, L, M) foruntested, winners, losers, <strong>and</strong> middles, respectively. For a set of n elements, theinitial st<strong>at</strong>e of the algorithm is (n, 0, 0, 0) <strong>and</strong> the end st<strong>at</strong>e is (0, 1, 1, n − 2). Thus,every run for any algorithm must go from st<strong>at</strong>e (n, 0, 0, 0) to st<strong>at</strong>e (0, 1, 1, n − 2).We also observe th<strong>at</strong> once an element is identified to be a middle, it can then beignored because it can neither be the minimum nor the maximum.Given th<strong>at</strong> there are four types of elements, there are 10 types of comparison.Comparing with a middle cannot be more efficient than other comparisons, so weshould ignore those, leaving six comparisons of interest. We can enumer<strong>at</strong>e theeffects of each comparison type as follows. If we are in st<strong>at</strong>e (i, j, k, l) <strong>and</strong> we havea comparison, then the st<strong>at</strong>e changes are as follows.U : U (i − 2, j + 1, k + 1, l)W : W (i, j − 1, k, l + 1)L : L (i, j, k − 1, l + 1)L : U (i − 1, j + 1, k, l)or (i − 1, j, k, l + 1)W : U (i − 1, j, k + 1, l)or (i − 1, j, k, l + 1)W : L (i, j, k, l)or (i, j − 1, k − 1, l + 2)Now, let us consider wh<strong>at</strong> an adversary will do for the various comparisons.The adversary will make sure th<strong>at</strong> each comparison does the least possible amountof work in taking the algorithm toward the goal st<strong>at</strong>e. For example, comparing awinner to a loser is of no value because the worst case result is always to learnnothing new (the winner remains a winner <strong>and</strong> the loser remains a loser). Thus,only the following five transitions are of interest:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!