page237.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 54 行
HTML
54 行
<HTML><HEAD><TITLE>Average Case Analysis</TITLE></HEAD><BODY bgcolor="#FFFFFF"> <a href="../index.html" target="_top"><img src="../icons/usins.gif" alt="Logo" align=right></a><b>Data Structures and Algorithms with Object-Oriented Design Patterns in Python</b><br><A NAME="tex2html3928" HREF="page238.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3926" HREF="page230.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3922" HREF="page236.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html3930" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION008520000000000000000">Average Case Analysis</A></H2><P>The previous section has shown thatthe worst-case running time to insertor to find an object into a chained scatter table is <I>O</I>(<I>M</I>).The average case analysis of chained scatter tables is complicatedby 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 itemsare identical to those which appear in a separately chained hash tablefor the same set of items.<P>Unfortunately we cannot assume that lists do not coalesce--they do!We therefore expect that the average list will be longer than <IMG WIDTH=8 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline62235" SRC="img936.gif" >and that the running times are correspondingly slower.Knuth has shown that the average number of probesin an unsuccessful search is<P> <IMG WIDTH=348 HEIGHT=33 ALIGN=BOTTOM ALT="displaymath62327" SRC="img965.gif" ><P>and the average number of probes in a successful search is approximately<P> <IMG WIDTH=368 HEIGHT=34 ALIGN=BOTTOM ALT="displaymath62328" SRC="img966.gif" ><P>where <IMG WIDTH=8 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline62235" SRC="img936.gif" > is the load factor[<A HREF="page610.html#knuth3">29</A>].The precise functional form of <IMG WIDTH=32 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline62343" SRC="img967.gif" > and <IMG WIDTH=30 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline62345" SRC="img968.gif" >is not so important here.What is important is that when <IMG WIDTH=37 HEIGHT=11 ALIGN=BOTTOM ALT="tex2html_wrap_inline62347" SRC="img969.gif" >,i.e., when the table is full, <IMG WIDTH=73 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline62349" SRC="img970.gif" > and <IMG WIDTH=72 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline62351" SRC="img971.gif" >.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!<P>Consequently, the average running time for insertion is<P> <IMG WIDTH=377 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath62329" SRC="img972.gif" ><P>since the insertion is always done in first empty position found.Similarly, the running time for an unsuccessful search is<P> <IMG WIDTH=369 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath62330" SRC="img973.gif" ><P>and for a successful search its<P> <IMG WIDTH=367 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath62331" SRC="img974.gif" ><P><HR><A NAME="tex2html3928" HREF="page238.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3926" HREF="page230.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3922" HREF="page236.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html3930" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <P><ADDRESS><img src="../icons/bruno.gif" alt="Bruno" align=right><a href="../copyright.html">Copyright © 2003</a> by <a href="../signature.html">Bruno R. Preiss, P.Eng.</a> All rights reserved.</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?