Back to index

CSC 378F Data Structures and Algorithm Analysis

AMORTIZED MTF 
Recall the optimal list :
amf_1.gif

where amf_2.gif

amf_3.gif is the probability that the next search is for amf_4.gif )

Move-to-Front Heuristic
We don't know the probabilities. The structure is a dynamic linked list; upon search for an item, that item is moved to the front of the list. In this way, frequently-sought items will tend to stay near the front.

What is amf_5.gif as compared to amf_6.gif ?

Probabilistic analysis shows that -

amf_7.gif
- but says nothing about the worst case.

We will show that -

amf_8.gif
This is a much stronger statement!

Amortized Analysis of MTF
Probabilistic analysis tells us what happens on average, not what happens in the worst case. Amortized analysis gives us the worst-case analysis for a sequence of operations.

Potential Method

Let amf_9.gif be the optimal static list.

Let amf_10.gif ( L ) be the number of pairs of elements of L which are in a different order in amf_11.gif ( called 'inversions' ).

 
e.g. amf_12.gif = a b c d 

L = a c d b 

amf_13.gif ( L ) = 2

 
What is the minimum amf_14.gif ( L ) ?
0 when L = amf_15.gif
What is the maximum amf_16.gif ( L )?
When L = reverse( amf_17.gif ), every pair is inversed,
there are amf_18.gif

Amortized Cost of One Search
Let amf_19.gif be L after the amf_20.gif search.
Let amf_21.gif be the amf_22.gif find operation on amf_23.gif .

amf_24.gif

( Let amf_25.gif be amf_26.gif in an optimal list )
From amf_27.gif to amf_28.gifamf_29.gif changes order with each element in A.
amf_30.gif 's order remains the same for the elements in B.
amf_31.gif precedes amf_32.gif in amf_33.gif .

Suppose amf_34.gif :

- the new inversion increases amf_35.gif by 1.

Suppose amf_36.gif :
- the inversion disappears, so amf_37.gif decreases by 1.

Let a be the number of elements amf_38.gif such that j < k.
a
is the number of inversions created.
|A| - a
is the number of inversions removed.

Then -

amf_39.gif

amf_40.gif

 amf_41.gif

 amf_42.gif we are paying 2 for each inversion created.

We want to compare amf_43.gif and amf_44.gif , the time to find amf_45.gif in amf_46.gif .
amf_47.gif

amf_48.gif amf_49.gif k is in the amf_50.gif position )

But 'a' is the number of elements amf_51.gif such that j < k,
which is amf_52.gif the number of elements amf_53.gif such that j < k,
which is amf_54.gif k - 1.

So amf_55.gif

amf_56.gif

amf_57.gif

amf_58.gif

But the list has some elements in it before the first 'find'. For the whole sequence :
amf_59.gif
amf_60.gif ,
where amf_61.gif
 amf_62.gif
 amf_63.gif

amf_64.gif

amf_65.gif

where amf_66.gif doesn't change as M increases.

So amf_67.gif

and amf_68.gif as amf_69.gif .

This is better than the probabilistic analysis, since it applies to all sequences of finds, not just the average case.

Back to index