Presentation is loading. Please wait.

Presentation is loading. Please wait.

optimal solution minimizing number of $3’s has at most one $3 ($3 + $3  $5 + $1) has at most two $1’s ($1+$1+$1  $3) has value at most $4 in $1 and.

Similar presentations


Presentation on theme: "optimal solution minimizing number of $3’s has at most one $3 ($3 + $3  $5 + $1) has at most two $1’s ($1+$1+$1  $3) has value at most $4 in $1 and."— Presentation transcript:

1

2 optimal solution minimizing number of $3’s has at most one $3 ($3 + $3  $5 + $1) has at most two $1’s ($1+$1+$1  $3) has value at most $4 in $1 and $3  has the same number of $5 as greedy sol yes

3 no 8 = 4 + 4 8 = 6 + 1 + 1

4 yes optimal solution minimizing number of $4’s has at most one $4 ($4 + $4  $7 + $1) has at most three $1’s ($1+$1+$1+$1  $4) has value at most $6 in $1 and $4  has the same number of $7 as greedy sol

5 MAIN IDEA: if there is a counterexample then there is a small counterexample 1<A<B

6 LEMMA: optimal solution for the smallest counterexample doesn’t contain B E = O 1 + O A * A + O B * B E = G 1 + G A * A + G B * B E-B = O 1 + O A * A + (O B -1)*B E-B = G 1 + G A * A + (G B -1)*B

7 LEMMA: optimal solution for the smallest counterexample doesn’t contain B copies of A (A+A+...+A  B+B+...+B) A copies of 1 (1+1+...+1  A) E  (B-1)*A + (A-1) = A*B-1

8 THEOREM: if there is a counterexample then there is on with E  A*B-1 MAIN IDEA: if there is a counterexample then there is a small counterexample

9 for all C  AB-1 find optimum (dynamic programming) check if agrees with greedy

10 LEMMA: greedy solution for the smallest counterexample doesn’t contain A E = O 1 + O A * A E = G 1 + G A * A + G B * B E-A = O 1 + (O A -1)* A E-A = G 1 + (G A -1)* A + G B *B

11 LEMMA: optimal solution for the smallest counterexample doesn’t contain 1 E = O 1 + O A * A E = G 1 + G B * B E-1 = (O 1 -1)+ O A * A E-1 = (G 1 -1)+ + G B * B

12 LEMMA: If there exists a counterexample, then there exists a counterexample E = O A * A E = G 1 + G B * B with O A <B and G 1 <A

13 LEMMA: If there exists a counterexample, then there exists a counterexample E = O A * A E = G 1 + G B * B with O A <B and G 1 <A with G B = 1

14 polynomial-time solution  check if P=  B/A  A is a counterexample 

15  check if P=  B/A  A is a counterexample 6 = 5 + 1 = 2*3 yes 8 = 6 + 1 + 1 = 2*4 no 8 = 7 +1 = 2*4 yes

16 each measurement has 3 outcomes 3 measurements  27 outcomes N=14  2*14 = 28 outcomes

17 SG S SGG 1/3 2/3

18 M[i,j] = min { P[j] + min M[k,j] + M[i-k,j] P[i] + min M[i,k] + M[i,j-k] 1  k  i-1 1  k  j-1

19 K[i,s]  K[i-1,s] if s  W[i] and K[i-1,s-W[i]]+V[i]>K[i,s] then K[i,s]  K[i-1,s-W[i]]+V[i]

20 M(m,n)=m * n - 1 proof: induction on m+n base case m+n=2  m=n=1 ok m * n  m 1 * n and m 2 * n, by IH (m 1 *n – 1) + (m 2 * n – 1 ) + 1 = m * n -1

21 binary search tree 5 47 2 13 depth  running time INSERT DELETE SEARCH

22 B-tree 5 47 2 1 3 branching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD) uniform depth INSERT DELETE SEARCH

23 B-tree branching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD)... 10 3 10 6 10 9

24 B-tree every node other than the root has  T-1 keys (i.e.,  T children) every node has  2T-1 keys (i.e.,  2T children) if T=2 the number of children is 2,3, or 4

25 B-tree - insert 102030 232429 2527 INSERT(T,26)

26 B-tree - insert 102030 232429 2527 INSERT(T,26)

27 B-tree - insert 102030 232429 2527 INSERT(T,26)

28 B-tree - insert 102030 232429 2526 INSERT(T,26) 27

29 B-tree - insert 102030 232429 2526 INSERT(T,28) 27 full leaf

30 B-tree - insert 102030 232429 2526 INSERT(T,28) 27 full leaf

31 B-tree - insert 102030 232429 2526 INSERT(T,28) 27 full leaf

32 B-tree - insert 10 20 30 232429 2526 INSERT(T,28) 27 full leaf

33 B-tree - insert 10 20 30 23 24 29 2526 INSERT(T,28) 27 full leaf

34 B-tree - insert 10 20 30 23 24 29 25 26 INSERT(T,28) 27 full leaf

35 B-tree - insert 10 20 30 23 24 29 25 26 INSERT(T,28) 27 full leaf 28

36 B-tree - insert 102030 232429 2527 INSERT(T,26) split proactively

37 B-tree - insert 10 20 30 232429 2527 INSERT(T,26) split proactively

38 B-tree - insert 10 20 30 232429 2527 INSERT(T,26) split proactively

39 B-tree - insert 10 20 30 23 24 29 2527 INSERT(T,26) split proactively

40 B-tree - insert 10 20 30 23 24 29 2527 INSERT(T,26) split proactively

41 B-tree - insert 10 20 30 23 24 29 25 INSERT(T,26) split proactively 2627

42 B-tree - insert 10 20 30 23 24 29 25 INSERT(T,28) split proactively 2627

43 B-tree - insert 10 20 30 23 24 29 25 INSERT(T,28) split proactively 26 2728

44 B-tree - insert 2T-1 keys  T-1 and T-1 keys every node other than the root has  T-1 keys (i.e.,  T children) every node has  2T-1 keys (i.e.,  2T children) uniform depth – the only operation increasing depth is splitting the root

45 B-tree - delete 10 20 30 23 24 29 25 26 2728 DELETE(T,28)

46 B-tree - delete 10 20 30 23 24 29 25 26 27 DELETE(T,28) leaf deletion

47 B-tree - delete 10 20 30 23 24 29 25 26 27 DELETE(T,27) leaf deletion ?


Download ppt "optimal solution minimizing number of $3’s has at most one $3 ($3 + $3  $5 + $1) has at most two $1’s ($1+$1+$1  $3) has value at most $4 in $1 and."

Similar presentations


Ads by Google