| Reading: | Wood, Chapter 2, Sections 2.2.1, 2.3.2 |
| Wood, Chapter 8, Sections 8.3.3, 8.3.4 | |
| Wood, Chapter 10, Sections 10.3 |
| 1. |
As discussed in the lecture notes, the worst-case time performance of a basic sequential search through an unordered list of elements is O(n) since every element of the list must be examined to see if it matches.
However, the expected-case performance can be improved if more frequently accessed items are kept at the front of the list (assuming a non-uniform probability distribution of item lookups).
In this case, the amortized case performance will also improve.
One way to achieve improved performance is using a move-to-front sequential search. In this search technique, an item is found by sequentially searching for the item from the front of the list as in an exhaustive search. However, if the item is found, the item is moved to the front of the list in the hope that subsequent searches for the item will find the item earlier on in the list than before. For simplicity, we will only move the first occurrence of the item; all other occurrences of the item in the list are left unmoved.
|