optimal solution minimizing number of $3’s has at most one $3 ($3 + $3 $5 + $1) has at most two...
Post on 19-Dec-2015
215 views
TRANSCRIPT
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
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
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
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
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
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
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
LEMMA: If there exists a counterexample,then there exists a counterexample E = OA * A E = G1 + GB * Bwith OA <B and G1<A
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
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
B-tree
5
4 7
2
1 3
branching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD)
uniform depth
INSERTDELETESEARCH
B-treebranching factor > 2 * makes balancing easier * efficient for “burst memory” (HDD)
. . .
. . .
103
106
109
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
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