Data Structures and Algorithms with Object-Oriented Design Patterns in C#
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_inline62017 and that the running times are correspondingly slower. Knuth has shown that the average number of probes in an unsuccessful search is

displaymath62109

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

displaymath62110

where tex2html_wrap_inline62017 is the load factor[29]. The precise functional form of tex2html_wrap_inline62125 and tex2html_wrap_inline62127 is not so important here. What is important is that when tex2html_wrap_inline62129, i.e., when the table is full, tex2html_wrap_inline62131 and tex2html_wrap_inline62133. 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

displaymath62111

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

displaymath62112

and for a successful search its

displaymath62113


next up previous contents index

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