Title: Static Optimality and Dynamic Search Optimality in Lists and Trees
1Static Optimalityand Dynamic Search
Optimalityin Lists and Trees
- Avrim Blum
- Shuchi Chawla
- Adam Kalai
1/6/2002
2List Update Problem
Query for element 9
- Unordered list
- Access for xi takes i time
3List Update Problem
Query for element 9
- Unordered list
- Access for xi takes i time
- Moving up accessed item is FREE!
- Other reorderings cost 1 per transposition
- Goal minimize total cost
- What should the reordering policy be?
4Binary Search Tree
7
2
12
9
14
5
4
15
- In-order tree
- Search cost depth of element
- Cost of rotations 1 per rotation
- Replacement policy ?
5How good is a reordering algorithm?
- Compare against the best offline algorithm
- Dynamic competitive ratio
- Best offline algorithm that cannot change state
of the list/tree -- static - Static competitive ratio
6Known results..
- List update
- Dynamic ratio Albers et al95, Teia93 u.b.-
1.6 l.b.- 1.5 - Trees
- Splay trees Sleator Tarjan 85 static ratio
3 - No known result on dynamic ratio
- Classic Machine Learning results
- Experts analysis LW94 static ratio (1 ?)
- Computationally inefficient
Recent new result Kalai Vempala01 Efficient
alg for Strong Static Optimality for trees
7Our results..
- List Update
- (1 ?) static ratio efficient variant of
Experts - We call this Strong static optimality
- Combining strong static optimality and dynamic
optimality to get best of both - Search trees
- Constant Dynamic ratio for trees
- Given free rotations
- ignoring computation time
8Revisiting Experts Algorithm Littlestone
Warmuth 94
- N expert algorithms
- We want to be (1?) wrt the best algorithm
- Weighted Majority algorithm
- Assign weights to each expert by how well it
performs - Pick probabilistically according to weights
- Cost incurred lt (1?)m ln(N)/(1-?)
- Applying this to list update
- Each list configuration is an expert
- Too many experts n!
- Can we reduce computation?
9Experts for List Update
- Weight for every static list too much
computation - The BIG idea
- Assign weights to every item in list and still
make an experts style analysis work!
10Candidate algorithm
- Initialize wi for item i
- If ith element accessed, update wi
- Order elements using some rule based on wi
- Need to analyze probability of getting a
particular static list
11Idea 2 List FactoringBorodin ElYaniv
- Distribute cost of accessing among pairs of
elements - Observation
- The relative order of x and y in the list does
not depend upon accesses to others - Implication
- Only need to analyze a two element list!
12Algorithm for two element list
- List (x,y)
- Experts (x,y) and (y,x)
- weights wx, wy
- correspond to the respective experts!
- Algorithm
- Initialize wx, wy to rx ry ?R 1..1/?
- If x accessed, wx lt- wx1 else wy lt- wy1
- Always keep the element with higher weight in
front
13Efficient Experts algorithm for List Update
- Select ri ?R 1..1/? for element i
- Initialize wi lt- ri
- If ith element accessed, wi lt- wi1
- Order elements in decreasing order of weight
- (1?) static competitive
- Kalai Vempala01 give a similar result for trees
14Combining Static Dynamic optimality
- A has strong static optimality, B has dynamic
optimality - Combine the two to get the best of both
- Apply Experts again
- Technical difficulties
- Cannot estimate weights running both
simultaneously defeats our purpose - Experts maintain state - Huge cost of switching
- Dont switch very often
15How to estimate weights?
- The Bandits approach Burch 00
- Bandit can sample at most one slot machine at a
time - Run the (so far) better expert
- Assume good behavior from the other
- - Pessimistic approach
- After a few runs, we have sampled each one
sufficiently - Details in the paper
16Binary Search Trees
- Splay trees achieve constant static ratio
- No results on dynamic optimality
- Simplifying the problem
- Allow free rotations
- Allow unlimited computation
- We give a constant dynamic ratio
17Outline of our approach
- Design a probability distribution p over
accesses - Low offline cost gt greater probability
- Assume p reflects reality and predict the next
access from it. - Construct tree based on conditional probability
of next access - Low offline cost gt node closer to root gt low
online cost
18An observation about offline BSTs
- An access sequence with offline cost k can be
expressed in 12k bits - At most 212k sequences of offline cost k.
19An observation about offline BSTs
- An access sequence with offline cost k can be
expressed in 12k bits - Express access sequence as rotations performed by
an offline algorithm - Start with a fixed tree, make some assumptions
about offline algorithm gives extra factor of 2 - Express rotations from one tree to another using
6 bits per rotation - At most 212k sequences of offline cost k.
20Probability distribution on accesses
- ? Distribution on access sequence a
- p(a) gt 2-13k where k offline cost of a
- Use this to calculate conditional probability of
next access - Construct tree such that
- Cost of accessing ? ln(1/p(a))
O(k)
21What next?
- Can we make this algorithm computationally
feasible? - True dynamic optimality for BST
- Strong static optimality solved recently KV01
- Lessons to take home
- Experts analysis is a useful tool for data
structures - Generic algorithm too slow
22Optimality
- Cost of ALG is at most a constant factor times
the cost of OPT - Dynamic optimality
- Static optimality
- Strong static optimality the ratio is (1?)
- Search optimality ignore our rotation cost
23Known results..
- List update
- Dynamic ratio Albers et al95, Teia93 u.b.-
1.6 l.b.- 1.5 - Trees
- Splay trees Sleator Tarjan 85 static ratio 3
24Back to list update
- How can we hope to achieve strong static
optimality? - Soln Use a classic machine learning result!!
- Experts Algorithm
25List Factoring Lemma
- Under a certain condition
- If A performs well on a list of two elements
- it performs well on any arbitrary list
- Condition
- For an arbitrary list, given the same accesses,
- A should order x and y just as in a list with
only x y
26List Factoring Lemma
9
9 and 4 retain the same order LFL applies
27An observation about offline BSTs
- An access sequence with offline cost k can be
expressed in 12k bits - At most 212k sequences of offline cost k.
28An observation about offline BSTs
- An access sequence with offline cost k can be
expressed in 12k bits - At most 212k sequences of offline cost k.
29Probability distribution on accesses
- ? Distribution on accesses a
- p(a) 2-13k where k offline cost of a
- Use this to calculate probability of next access
- Caveat
- computationally infeasible
- But dynamic search optimal !
30Binary Search Tree
9
7
12
Query for element 9
2
14
15
5
4
- In-order tree
- Search cost depth of element
- Cost of rotations 1 per operation
- Replacement policy ?
31Why is BST harder?
- Decide which nodes should be near the root
- Decide how to move up those nodes
- Not straightforward
- 132 different ways of bringing a node at depth 7
to the root!! - We ignore the second issue
- try for Dynamic search optimality
329
7
7
12
4
12
4
14
9
14
5
2
15
5
2
15
(left,up,right,up)
- Uniquely specifies rotations
33An observation about offline BSTs
- An access sequence with offline cost k can be
expressed in 12k bits - Start with a fixed tree
- Express rotations from one tree to another using
6 bits per rotation - Assume algorithm first brings accessed element to
root extra factor of 2 - At most 212k sequences of offline cost k.
34Outline of our approach
- Design a probability distribution p over
accesses - Low offline cost gt greater probability
- Assume p reflects reality and predict the next
access from it. - Construct tree based on conditional probability
of next access - Low offline cost gt node closer to root gt low
online cost