A self-organizing list is a linked list of n elements, in which each element has a unique

Question:

A self-organizing list is a linked list of n elements, in which each element has a unique key. When we search for an element in the list, we are given a key, and we want to find an element with that key.

A self-organizing list has two important properties.

1. To find an element in the list, given its key, we must traverse the list from the beginning until we encounter the element with the given key. If that element is the?kth element from the start of the list, then the cost to find the element is?k.

2. We may reorder the list elements after any operation, according to a given rule with a given cost. We may choose any heuristic we like to decide how to reorder the list.

Assume that we start with a given list of?n?elements, and we are given an access sequence ??=????1,??2, . . . ,??m??of keys to find, in order. The cost of the sequence is the sum of the costs of the individual accesses in the sequence.

Out of the various possible ways to reorder the list after an operation, this problem focuses on transposing adjacent list elements-switching their positions in the list-with a unit cost for each transpose operation. You will show, by means of a potential function, that a particular heuristic for reordering the list, move-to-front, entails a total cost no worse than 4 times that of any other heuristic for maintaining the list order-even if the other heuristic knows the access sequence in advance! We call this type of analysis a competitive analysis.

For a heuristic H and a given initial ordering of the list, denote the access cost of sequence by CH(?). Let m be the number of accesses in ?.

a. Argue that if heuristic H does not know the access sequence in advance, then the worst-case cost for H on an access sequence is CH (?) = ?(mn).

With the?move-to-front?heuristic, immediately after searching for an element?x, we move?x?to the first position on the list (i.e., the front of the list).

Let rankL(x)?denote the rank of element?x?in list?L, that is, the position of?x?in list?L. For example, if?x?is the fourth element in?L, then rankL(x)?=?4. Let?ci denote the cost of access i using the move-to-front heuristic, which includes the cost of finding the element in the list and the cost of moving it to the front of the list by a series of transpositions of adjacent list elements.

b. Show that if i accesses element x in list L using the move-to-front heuristic, then ci = 2 ? rankL(x)-1.

Now we compare move-to-front with any other heuristic H that processes an access sequence according to the two properties above. Heuristic H may transpose elements in the list in any way it wants, and it might even know the entire access sequence in advance.

Let?Li be the list after access ?i using move-to-front, and let L*i be the list after access i using heuristic H. We denote the cost of access i by ci for move-to-front and by c*i for heuristic H. Suppose that heuristic H performs t*i transpositions during access ?i.

c.?In part (b), you showed that?ci = 2 ? rankLi_1(x)??1. Now show that?c*i = rankL*i-1 (x) + t*i.

We define an?inversion?in list?Li as a pair of elements y and z such that y precedes z in Li and z precedes y in list L*i. Suppose that list?Li has qi inversions after processing the access sequence ??1,??2,.. .,??i?. Then, we define a potential function ? that maps Li to a real number by ?(Li)?=?2qi. For example, if?Li has the elements ?e, c, a, d, b? and L*i has the elements ?c, a, b, d, e?, then Li has 5 inversions ((e, c), (e, a), (e, d), (e, b), (d, b)), and so ?(Li) = 10. Observe that ?(Li) ??0?for all?i?and that, if move-to-front and heuristic H start with the same list?L0, then??(L0)?=?0.

d.?Argue that a transposition either increases the potential by?2?or decreases the potential by?2.

Suppose that access ?i finds the element x. To understand how the potential changes due to ?i, let us partition the elements other than x into four sets, depending on where they are in the lists just before the i th access.

  • Set A consists of elements that precede x in both Li-1 and L*i-1.
  • Set?B?consists of elements that precede?x?in?Li-1 and follow x in L*i-1.
  • Set?C?consists of elements that follow?x?in?Li-1 and precede x in L*i-1.
  • Set?D?consists of elements that follow?x?in both?Li-1 and L*i-1.

e. Argue that rankLi-1(x) = |A| + |B| + 1 and rankL*i-1(x) = |A| + |C| + 1.

f. Show that access i causes a change in potential of

image

where, as before, heuristic H performs t*i transpositions during access ?i.

Define the amortized cost c ?i of access ?i by c ?i = ci + ?(Li)-??(Li-1).

g. Show that the amortized cost c ?i of access i is bounded from above by 4c*i.

h. Conclude that the cost CMTF(?) of access sequence with move-to-front is at most 4 times the cost CH(?) of ? with any other heuristic H, assuming that both heuristics start with the same list.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Introduction to Algorithms

ISBN: 978-0262033848

3rd edition

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

Question Posted: