Download presentation
Presentation is loading. Please wait.
Published byWalter Pearson Modified over 9 years ago
1
HSR Help Karl Lieberherr 1/23/20111Asymptotic Growth
2
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/20112Asymptotic Growth
3
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/20113Asymptotic Growth
4
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/20114Asymptotic Growth
5
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 2 3 4 5 6 7 1/23/20115Asymptotic Growth
6
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 2 3 4 5 6 7 3 1/23/20116Asymptotic Growth
7
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/20117Asymptotic Growth
8
Magic for now 0 1 2 3 4 5 6 7 8 9 10 * * * * * * * HSR(11,2)=4 M(2,4)=11 * * * HSR(7,2)=3 M(2,3)=7 HSR(4,1)=3 M(1,3)=4 HSR(4,2)=2 M(2,2)=4 HSR(3,1)=2, M(1,2)=3 1/23/20118Asymptotic Growth
9
* ** ** * * 40* ** *******8**** * ***** * HSR(11,2)=4 M(2,4)=11 M(k,q)=n 4 choose 2 = 6 4 choose 1 = 4 4 choose 0 = 1 11 = sum= M(2,4) Claim: For all k,q (k<=q): M(k,q) = Sum[i=0 to k](q choose i) 1/23/20119Asymptotic Growth
10
HSR Question 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/201110Asymptotic Growth
11
Definition of M recurrence: M(k,q) = M(k-1,q-1) + M(k,q-1) M(0,q) = 1 M(k,k) = 2 k M(0,q): 0 jars to break M(k,k): k jars to break and q=k questions to ask: use binary search. 1/23/201111Asymptotic Growth
12
M = SF M ~ Modified Pascal SF ~ Sum Formula M(k,q)) = M(k-1,q-1) + M(k,q-1) M(0,q) = 1 M(q, q) = 2^q SF(k,q) = Sum[i=0 to k](q choose i) in Theta(q^k) SF has the following properties: (1) SF(0,q) = q choose 0 = 1 = M(0,q) (2) SF(q, q) = Sum[i=0 to q] q choose i = 2^q = M(q, q) (3) SF(k, q) = SF(k-1, q-1) + SF(k,q-1) 1/23/201112Asymptotic Growth
13
3rd property (Ahmed) SF(X-1, Y-1) + SF(X-1, Y) = Sum[i=0 to Y-1] X-1 choose i + Sum[i=0 to Y] X-1 choose i = Sum[i=0 to Y-1] X-1 choose i + Sum[i=1 to Y] X-1 choose i + X-1 choose 0 = Sum[i=0 to Y-1] X-1 choose i + Sum[i=0 to Y-1] X-1 choose (i+1) + 1 = Sum[i=0 to Y-1] ( X-1 choose i + X-1 choose (i+1) ) + 1 = Sum[i=0 to Y-1] ( X choose (i+1) ) + 1 = Sum[i=0 to Y-1] ( X choose (i+1) ) + X choose 0 = Sum[i=1 to Y] ( X choose i ) + X choose 0 = Sum[i=0 to Y] ( X choose i ) = SF(X, Y) Therefore, SF(X,Y) = M(X,Y). X=q,Y=k, switch X and Y 1/23/201113Asymptotic Growth
14
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/201114Asymptotic Growth
15
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/201115Asymptotic Growth
16
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/201116Asymptotic Growth
17
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 2 3 4 5 6 7 1/23/201117Asymptotic Growth
18
HSR Asymptotic Growth 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 2 3 4 5 6 7 3 1/23/201118Asymptotic Growth
19
HSR Iterative 1 1 2 1 3 4 1 4 7 8 1 5 11 15 16 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 jars to break: k 0 1 questions asked: q 2 0 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 M: maximum number of rungs n rungs: 0,1,2,3, …,n-1 1/23/201119Asymptotic Growth 1 4 11 1 5 16 1 b c 1 b+1 b+1+c
20
What is the running time of our decision tree construction algorithm? Input: (n,k), k<=n Output: decision tree of minimum depth that correctly determines the highest safe rung for a ladder with rungs 0..n-1 and k jars to break. Algorithm: – Construct slice of modified Pascal Triangle – Determine tree structure from Pascal Triangle – Fill in rung questions internal to tree What is its asymptotic running time? 1/23/2011Asymptotic Growth20
21
Claim Alice claims: she can construct DT(n,k) in time O(f(n,k)). Express bound as a function of output size. 1/23/2011Asymptotic Growth21
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.