Move To Front Lists

A quick and easy way to optimize unsorted LinearSearch lists. Each time you search for an item, put the found item at the front of the list. Popular items tend to be closer to the beginning of the list and are found quicker. Depending on the probability distribution of the searches, this simple method can improve the average performance of the search up to O(1). The worst case remains O(N). More typical performance is to simply lower the constant factor of an O(N) search. Occasionally, you might end up with O(lg N).


EditText of this page (last edited March 13, 2002) or FindPage with title or text search