day5 1/26/98 Quote of the day: ``Just leave it out.''
1. Linear Programming
The constraints can be divided into 3 sets:
- H+ = {i:y ³ aix+bi}
- H- = {i:y £ aix+bi}
- H0 = {i:aix = bi} (vertical line constraints)
In general only 2 of the constraints in H0 can be active at one time.
Define:
- lt+ Î H+ with largest intersection on line x = t
- lt- Î H- with smallest intersection on line x = t
By looking at the slopes of lt+ and lt- you can decide whether the solution must
lie to the left or to the right.
1.1 Algorithm
This algorithm is dual to the bridge finding algorithm in the convex hull problem.
Start with a window(a,b) in which the solution must lie.
- Pair up lines in H+ , Pair up lines in H- .
- compute » n/2 intersections
- pick t = median x value from the intersections. Let lt- = the smallest y-value which
any solution must lie below and lt+ = the largest y value which any solution must
lie above.
- case 1: lt- > lt+ (there exists a feasible region) if slope( lt+ )=0 then you are done,
else if slope( lt+ )>0, pick window(a,t) else pick window(t,b)
- case 2: lt- < lt+ if slope(lt+)-slope(lt-) > 0 then pick window(t,b) else pick window(a,t).
- case 3: : lt- = lt+ degenerate nastiness.
- For each pair with an intersection outside the new window discard a constraint.
- repeat with new window and remaining constraints.
1.2 Timing:
Timing is the same as the bridge algorithm.
T(n) = T(3/4*n)+c*n
2. Amortized analysis
2.1 Binary counter
How many bits change on average?
- Let Ci = counter at time i . C0 = all zeros
- potential function: #(Ci) = # of ones in counter.
- [^(costi)] = costi+#(Ci+1)-#(Ci) = amortized cost
To figure out the total cost, do (å[^(costi)]+#Cbegin-#Cend)/n = amortized cost. The amortized cost for a
the binary counter is 2. One way to see this is to notice that when the counter
is updated there is a p = 1 chance of 1 bit changing, a p = 1/2 chance of another bit
changing, a p = 1/4 chance of another bit changing.... the series sums to 2.
2.2 Splay trees
2.2.1 binary search trees
Common to all ordered trees
- each of the nodes stores at least one key.
- keys are ``inorder''
- member(i,S)
- insert(i,S)
- delete(i,S)
- join(S,S')
- split(i,S)
- AVL-trees (everything with log(n) or log(n)+1 trees)
- 2-3-4 trees (similar)
- red-black trees (depth varies between log(n) and 2*log(n))
- splay trees (move interesting elements to the root of the tree)
- random trees
The important method of transforming a binary tree is rotation of a child to
a parent. Splay trees rotate any element looked at to the top of the tree.
File translated from TEX by TTH, version 1.30.