In list
, let element
be in the
position in the list:
Let's try a proof by contradiction: Assume that
has minimum
and that there is some pair of adjacent elements that are
not ordered by decreasing probability of access:
If we can show that
does not have minimum cost, then the
assumption is contradicted and
in the minimum-cost list.
The expected access time in
is
Create another list,
, in which elements
and
are swapped. Let
be the access time in this list.
You might guess that this list has lower expected access time,
since
, which has higher probability of access, is now closer
to the front of the list. Let's see:
If the new list has lower expected access time, then
. In other words,
.
But our assumption was that
. This means that
and the new list does have lower expected access time!
Thus, the assumption is contradicted and we must conclude that, if
has minimum expected access time,