G. Manacher, S. Graham
Massachusetts Institute of Technology
This paper examines a class of heuristics for main-
taining a sequential list in approximately optimal
the average time
required to search for
a specified element, assuming that each element is
searched for with a fixed
previous searches performed. The "move to
heuristics are shown to be optimal
within a constant factor, and the transposition rule is
efficient of the two. Empirical
is in fact
for any distribution
of search probabilities.
Phrases: searching, self-organizing,
CR Categories: 3.74, 5.25
Heuristics for Maintaining a Sequential List
We consider heuristics for maintaining a sequential
list in approximately optimal order, prove that the
"transposition" heuristic is more efficient than the
"move to front" heuristic analyzed by Knuth in [6, pp.
Copyright (~) 1976, Association for Computing Machinery, Inc.
General permission to republish, but not for profit, all or part
of this material is granted provided that
is given and that reference is made to the publication, to its date
of issue, and to the fact that reprinting privileges were granted
by permission of the Association for Computing Machinery.
This work was performed at Institut de Recherche d'Informa-
tique et d'Automatique, 78-Rocquencourt, France, and completed
at MIT under NSF research grant no. GJ-43634X. Author's pres-
ent address: M1T, Project
NE43-804, 545 Technology
Square, Cambridge, MA 02139.
398-399], and present experimental evidence that the
transposition heuristic is in fact optimal.
Suppose we have a set of n records R1, Rx,.
which we list in an arbitrary order r, so that Ri is in
position r(i) for l < i < n. At each instant of time we
are presented with a key Ki and asked to retrieve the
associated record Ri. We do so by examining in turn
each position of the list until Ri is found in position 7r(i).
This search costs r(i) units of time to perform.
Let us assume that each key Ki is presented in-
dependently with probability p~. The expected cost
(average search length) for a permutation r is then
We assume without loss of generality throughout that
pl _> p;+l for 1 < i < n. Thus
is minimized when
r is the identity permutation, since the records are then
in order of decreasing probability of being requested.
In practice, the relevant probabilities p~ are seldom
known a priori, so that the optimal ordering can not be
arranged in advance. A random initial arrangement can
be expected to perform ~poorly, so we consider self-
organizing schemes by which the initial ordering is
gradually transformed on the basis of experience into a
hopefully less costly arrangement.
A "counter" scheme immediately spfi:'gs to mind,
whereby we record the frequencyf~ of requests for each