{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


cs320-2010-t1-sample-midterm2-solution - CPSC 320 Sample...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CPSC 320 Sample Midterm 2 November 2010 [6] 1. Short Answers [3] a. If we can not use a recursion tree to prove a tight bound on the value of a func- tion T ( n ) defined by a recurrence relation, can we use the Master theorem instead? Explain why or why not. Solution : The proof of the Master theorem used recursion trees, so if we can use the Master theorem to prove a bound on T ( n ) then we can also use recursion trees. Hence if we can not use recursion trees, then we can not use the Master theorem either. [3] b. The first (and only) result we looked at in our outline of the proof of the Master theorem stated that T ( n ) = n log b a + t - 1 summationdisplay i =0 a i f ( n/b i ) Explain where the term a i f ( n/b i ) came from, by relating each factor to the tool we used to prove the lemma. Solution : The i th row of the recursion tree contained a i nodes, since each node of the tree has a children. Each node worked on n/b i elements (the size of the subproblems at one level are 1 /b th the size of the subproblems at the next higher level), hence doing f ( n/b i ) work. [5] 2. In class, we looked at an implementation of a binary counter, and proved that if we use as potential function Φ( D i ) the number of 1 bits in the counter, then the amortized cost of an INCREMENT operation is in Θ(1) . Suppose instead that we had used the number of 0 bits in the counter as the potential function (note: this breaks the requirement that Φ( D 0 ) = 0 , so it would not be a valid choice). What would the amortized cost of
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}