This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Selforganizing 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 movetofront ( MTF ), where the current item being accessed is always moved to the front of the array. We will study the expected cost of movetofront, 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 movetofront 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
This note was uploaded on 02/21/2012 for the course PSYCH 101 taught by Professor Ennis during the Winter '09 term at Waterloo.
 Winter '09
 Ennis
 Psychology

Click to edit the document details