Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

Average Case Analysis

The previous section has shown that the worst-case running time to insert or to find an object into a chained scatter table is O(M). The average case analysis of chained scatter tables is complicated by the fact that lists coalesce. However, if we assume that chains never coalesce, then the chains which appear in a chained scatter table for a given set of items are identical to those which appear in a separately chained hash table for the same set of items.

Unfortunately we cannot assume that lists do not coalesce--they do! We therefore expect that the average list will be longer than tex2html_wrap_inline62235 and that the running times are correspondingly slower. Knuth has shown that the average number of probes in an unsuccessful search is

displaymath62327

and the average number of probes in a successful search is approximately

displaymath62328

where tex2html_wrap_inline62235 is the load factor[29]. The precise functional form of tex2html_wrap_inline62343 and tex2html_wrap_inline62345 is not so important here. What is important is that when tex2html_wrap_inline62347, i.e., when the table is full, tex2html_wrap_inline62349 and tex2html_wrap_inline62351. Regardless of the size of the table, an unsuccessful search requires just over two probes on average, and a successful search requires just under two probes on average!

Consequently, the average running time for insertion is

displaymath62329

since the insertion is always done in first empty position found. Similarly, the running time for an unsuccessful search is

displaymath62330

and for a successful search its

displaymath62331


next up previous index

Bruno Copyright © 2003, 2004 by Bruno R. Preiss, P.Eng. All rights reserved.