mid_sols

mid_sols - CSE 101 Midterm Solutions Chris Calabro 1...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSE 101 Midterm Solutions Chris Calabro July 23, 2009 1 Recurrence relation Suppose T (1) = 1 and for n > 1, T ( n ) = 4 T ( n 2 ) + 1. Claim 1. If n is a power of 2 , then T ( n ) = 4 3 n 2- 1 3 . Proof. We use induction on n . If n = 1, then T (1) = 1 = 4 3 · 1 2- 1 3 . If n > 1, then by the induction hypothesis, T ( n ) = 4 4 3 n 2 2- 1 3 + 1 = 4 3 n 2- 1 3 . One could also use the Master theorem to find the asymptotic growth rate of T , but that is not as specific as the above. 2 Median of 2 sorted lists Let X = ( X 1 ,...,X n ) ,Y = ( Y 1 ,...,Y n ) be 2 sorted lists of n elements each. For the purposes of this problem, the median of a list of size 2 n is the n th smallest element. The problem is to find the median of X ∪ Y . Let’s generalize the problem a little to finding the k th smallest element of 2 lists, X of size m and Y of size n . If m = 0, then this is Y k . If n = 0, then this is X k . But otherwise, m,n ≥ 1. If X d m 2 e > Y d n 2 e , then swap X,Y (and m,n ). So without loss of generality,)....
View Full Document

This note was uploaded on 03/16/2010 for the course CSE 101 taught by Professor Staff during the Winter '08 term at UCSD.

Page1 / 2

mid_sols - CSE 101 Midterm Solutions Chris Calabro 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online