optimal solution minimizing number of $3’s has at most one $3

47

description

yes. 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. no. 8 = 4 + 4 8 = 6 + 1 + 1. yes. - PowerPoint PPT Presentation

Transcript of optimal solution minimizing number of $3’s has at most one $3

Page 1: optimal solution minimizing number of $3’s has at most one $3
Page 2: optimal solution minimizing number of $3’s has at most one $3

optimal solution minimizing number of $3’shas 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 $3has the same number of $5 as greedy sol

yes

Page 3: optimal solution minimizing number of $3’s has at most one $3

no

8 = 4 + 48 = 6 + 1 + 1

Page 4: optimal solution minimizing number of $3’s has at most one $3

yes

optimal solution minimizing number of $4’shas 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 $4has the same number of $7 as greedy sol

Page 5: optimal solution minimizing number of $3’s has at most one $3

MAIN IDEA: if there is a counterexample then there is a small counterexample

1<A<B

Page 6: optimal solution minimizing number of $3’s has at most one $3

LEMMA: optimal solution for the smallest counterexample doesn’t contain B

E = O1 + OA * A + OB * B E = G1 + GA * A + GB * B

E-B = O1 + OA * A + (OB-1)*BE-B = G1 + GA * A + (GB-1)*B

Page 7: optimal solution minimizing number of $3’s has at most one $3

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

Page 8: optimal solution minimizing number of $3’s has at most one $3

THEOREM: if there is a counterexample thenthere is on with E A*B-1

MAIN IDEA: if there is a counterexample then there is a small counterexample

Page 9: optimal solution minimizing number of $3’s has at most one $3

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

Page 10: optimal solution minimizing number of $3’s has at most one $3

LEMMA: greedy solution for the smallest counterexample doesn’t contain A

E = O1 + OA * A E = G1 + GA * A + GB * B

E-A = O1 + (OA-1)* A E-A = G1 + (GA-1)* A + GB*B

Page 11: optimal solution minimizing number of $3’s has at most one $3

LEMMA: optimal solution for the smallest counterexample doesn’t contain 1

E = O1 + OA * A E = G1 + GB * B

E-1 = (O1-1)+ OA * A E-1 = (G1-1)+ + GB * B

Page 12: optimal solution minimizing number of $3’s has at most one $3

LEMMA: If there exists a counterexample,then there exists a counterexample E = OA * A E = G1 + GB * Bwith OA <B and G1<A

Page 13: optimal solution minimizing number of $3’s has at most one $3

LEMMA: If there exists a counterexample,then there exists a counterexample E = OA * A E = G1 + GB * Bwith OA <B and G1<A

with GB = 1

Page 14: optimal solution minimizing number of $3’s has at most one $3

polynomial-time solution

check if P= B/AA is a counterexample

Page 15: optimal solution minimizing number of $3’s has at most one $3

check if P= B/AA is a counterexample

6 = 5 + 1 = 2*3 yes

8 = 6 + 1 + 1 = 2*4 no

8 = 7 +1 = 2*4 yes

Page 16: optimal solution minimizing number of $3’s has at most one $3

each measurement has 3 outcomes3 measurements 27 outcomes

N=14 2*14 = 28 outcomes

Page 17: optimal solution minimizing number of $3’s has at most one $3

S G S SG G

1/3 1/3 1/3

2/3

Page 18: optimal solution minimizing number of $3’s has at most one $3

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

P[i] + min M[i,k] + M[i,j-k]

1ki-1

1kj-1

Page 19: optimal solution minimizing number of $3’s has at most one $3

K[i,s] K[i-1,s]if sW[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]

Page 20: optimal solution minimizing number of $3’s has at most one $3

M(m,n)=m * n - 1

proof: induction on m+n

base case m+n=2 m=n=1 ok

m * n m1 * n and m2 * n, by IH (m1*n – 1) + (m2 * n – 1 ) + 1 = m * n -1

Page 21: optimal solution minimizing number of $3’s has at most one $3

binary search tree

5

4 7

2

1 3

depth running time

INSERTDELETESEARCH

Page 22: optimal solution minimizing number of $3’s has at most one $3

B-tree

5

4 7

2

1 3

branching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD)

uniform depth

INSERTDELETESEARCH

Page 23: optimal solution minimizing number of $3’s has at most one $3

B-treebranching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD)

. . .

. . .

103

106

109

Page 24: optimal solution minimizing number of $3’s has at most one $3

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

Page 25: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 27

INSERT(T,26)

Page 26: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 27

INSERT(T,26)

Page 27: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 27

INSERT(T,26)

Page 28: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 26

INSERT(T,26)

27

Page 29: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 26

INSERT(T,28)

27

full leaf

Page 30: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 26

INSERT(T,28)

27

full leaf

Page 31: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 26

INSERT(T,28)

27

full leaf

Page 32: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23 24 29

25 26

INSERT(T,28)

27

full leaf

Page 33: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25 26

INSERT(T,28)

27

full leaf

Page 34: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25

26

INSERT(T,28)

27

full leaf

Page 35: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25

26

INSERT(T,28)

27

full leaf

28

Page 36: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10 20 30

23 24 29

25 27

INSERT(T,26)

split proactively

Page 37: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23 24 29

25 27

INSERT(T,26)

split proactively

Page 38: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23 24 29

25 27

INSERT(T,26)

split proactively

Page 39: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25 27

INSERT(T,26)

split proactively

Page 40: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25 27

INSERT(T,26)

split proactively

Page 41: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25

INSERT(T,26)

split proactively

26 27

Page 42: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25

INSERT(T,28)

split proactively

26 27

Page 43: optimal solution minimizing number of $3’s has at most one $3

B-tree - insert

10

20

30

23

24

29

25

INSERT(T,28)

split proactively

26

27 28

Page 44: optimal solution minimizing number of $3’s has at most one $3

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

Page 45: optimal solution minimizing number of $3’s has at most one $3

B-tree - delete

10

20

30

23

24

29

25

26

27 28

DELETE(T,28)

Page 46: optimal solution minimizing number of $3’s has at most one $3

B-tree - delete

10

20

30

23

24

29

25

26

27

DELETE(T,28)

leaf deletion

Page 47: optimal solution minimizing number of $3’s has at most one $3

B-tree - delete

10

20

30

23

24

29

25

26

27

DELETE(T,27)

leaf deletion

?