Cover Data Structures and Algorithms with Object-Oriented Design Patterns in Java
next up previous contents 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_inline61750 and that the running times are correspondingly slower. Knuth has shown that the average number of probes in an unsuccessful search is

displaymath61842

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

displaymath61843

where tex2html_wrap_inline61750 is the load factor[27]. The precise functional form of tex2html_wrap_inline61858 and tex2html_wrap_inline61860 is not so important here. What is important is that when tex2html_wrap_inline61862, i.e., when the table is full, tex2html_wrap_inline61864 and tex2html_wrap_inline61866. 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

displaymath61844

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

displaymath61845

and for a successful search its

displaymath61846


next up previous contents index

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