210 likes | 357 Views
HSR Help. Karl Lieberherr. HSR Asymptotic Growth. n rungs: 0,1,2,3, … ,n-1. 0. M: maximum number of rungs. questions asked: q. jars to break: k. 1. 1 1 2 1 3 4
E N D
HSR Help Karl Lieberherr Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 5 4 3 6 7 0 2 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 1 1 2 1 3 4 1 4 7 8 1 5 11 1516 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 5 4 3 7 6 0 2 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 3 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
Magic for now HSR(11,2)=4 M(2,4)=11 * HSR(7,2)=3 M(2,3)=7 HSR(4,1)=3 M(1,3)=4 * * * * * * * * * 0 1 2 3 4 5 6 7 8 9 10 HSR(4,2)=2 M(2,2)=4 HSR(3,1)=2, M(1,2)=3 Asymptotic Growth
HSR(11,2)=4 M(2,4)=11 M(k,q)=n * * * * * * * * * * * * * * * 0 * * * 4 * * * 8 * * * * * * * Claim: For all k,q (k<=q): M(k,q) = Sum[i=0 to k](q choose i) 4 choose 2 = 6 4 choose 1 = 4 4 choose 0 = 1 11 = sum= M(2,4) Asymptotic Growth
HSR Question n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
Definition of M • M(0,q): 0 jars to break • M(k,k): k jars to break and q=k questions to ask: use binary search. recurrence: M(k,q) = M(k-1,q-1) + M(k,q-1) M(0,q) = 1 M(k,k) = 2k Asymptotic Growth
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) Asymptotic Growth
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 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 5 4 3 6 7 0 2 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 Asymptotic Growth
HSR Asymptotic Growth n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 1 1 2 1 3 4 1 4 7 8 1 5 11 1516 1 6 16 26 31 32 1 7 22 42 57 63 64 1 8 29 64 99 120 127 128 5 4 3 7 6 0 2 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 3 Asymptotic Growth
HSR Iterative n rungs: 0,1,2,3, … ,n-1 0 M: maximum number of rungs questions asked: q jars to break: k 1 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 0 2 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 1 4 11 1 5 16 1 b c 1 b+1 b+1+c Asymptotic Growth
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? Asymptotic Growth
Claim • Alice claims: she can construct DT(n,k) in time O(f(n,k)). • Express bound as a function of output size. Asymptotic Growth