module6 - Self-organizing Search We consider a list of n...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Self-organizing Search We consider a list of n distinct items, say 1 , 2 ,...,n , stored in an array A . Items are accessed according to some fixed probability distribution: Pr[ i is accessed] = p i , 1 i n . Every access of an item is an independent event . WLOG we will assume that p 1 p 2 p n . Items are accessed sequentially, via a linear search . Therefore the cost of accessing an item x i (at a given point of time) is equal to the index k such that A [ k ] = x i . 122 / 193 Request Sequences and Static Orderings Consider a static ordering of the n items. Let i denote the position in the list where item i is placed, i.e., A [ i ] = i for i = 1 ,...,n . Observe that is a permutation of { 1 ,...,n } . i is also the cost of accessing item i . The expected cost of the ordering , denoted C ( ), is a weighted average that can be computed as follows: C ( ) = n X j =1 j p j . A request sequence is a list of requests, r = ( r 1 ,...,r m ), which is made according to the given probability distribution. We have r j { 1 ,...,n } for 1 j m . The average cost of accessing the items in the request sequence r is equal to C ( ). 123 / 193 Optimal Static Ordering The optimal static ordering is the ordering that yields the minimum expected cost. It can be shown that the optimal static ordering is the ordering 1 , 2 ,...,n . (Intuitively, this seems reasonable: we are placing the most frequently accessed items towards the front of A .) The permutation is the identity permutation , where j = j , 1 j n . The optimal expected cost , which is attained by the optimal static ordering, is computed to be C oso = n X j =1 j p j . 124 / 193 Dynamic Orderings A static ordering works well if the probability distribution is known ahead of time. If the probability distribution is not known, then we can employ a dynamic ordering in which the array is rearranged every time an item is accessed, using a certain heuristic . A popular heuristic is move-to-front ( MTF ), where the current item being accessed is always moved to the front of the array. We will study the expected cost of move-to-front, which we denote by C mtf , and compare it to C opt . For simplicity, suppose that we have only two items, 1 and 2. The cost of accessing an item i is 1 if the item i was the last item accessed ; otherwise the cost is 2. Let p 1 = p ; and p 2 = q ; then q = 1- p . Recall that we are assuming that p 1 p 2 , so p 1 / 2 and q 1 / 2. 125 / 193 Comparison of C mtf and C oso When using the move-to-front heuristic with two items, the probability that two consecutive accesses are for the same item is p 2 + q 2 , and the probability that two consecutive accesses are for different items is 1- ( p 2 + q 2 ) = 2 pq ....
View Full Document

Page1 / 34

module6 - Self-organizing Search We consider a list of n...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online