page238.html

来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 62 行

HTML
62
字号
<HTML><HEAD><TITLE>Scatter Table using Open Addressing</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="tex2html3939" HREF="page239.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3937" HREF="page205.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3931" HREF="page237.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html3941" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION008600000000000000000">Scatter Table using Open Addressing</A></H1><P>An alternative method of dealing with collisions which entirely does away with the need for links and chainingis called <em>open addressing</em><A NAME=12578>&#160;</A>.The basic idea is to define a <em>probe sequence</em><A NAME=12580>&#160;</A>for every key which, when followed, always leads to the key in question.<P>The probe sequence is essentially a sequence of functions<P> <IMG WIDTH=316 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath62353" SRC="img975.gif"  ><P>where  <IMG WIDTH=12 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62361" SRC="img976.gif"  > is a hash function,  <IMG WIDTH=185 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline62363" SRC="img977.gif"  >.To insert item <I>x</I> into the scatter table,we examine array locations  <IMG WIDTH=35 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline62367" SRC="img978.gif"  >,  <IMG WIDTH=36 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline62369" SRC="img979.gif"  >, ...,until we find an empty cell.Similarly, to find item <I>x</I> in the scatter tablewe examine the same sequence of locations in the same order.<P>The most common probe sequences are of the form<P> <IMG WIDTH=351 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath62354" SRC="img980.gif"  ><P>where  <IMG WIDTH=129 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62247" SRC="img938.gif"  >.The function <I>h</I>(<I>x</I>) is the same hash function that we have seen before.That is, the function <I>h</I> maps keysinto integers in the range from zero to <I>M</I>-1.<P>The function <I>c</I>(<I>i</I>) represents the collision resolution strategy.It is required to have the following two properties:<DL ><DT><STRONG>Property 1</STRONG><DD> <I>c</I>(0)=0.	This ensures that the first probe in the sequence is	<P> <IMG WIDTH=370 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath62355" SRC="img981.gif"  ><P>    <DT><STRONG>Property 2</STRONG><DD> The set of values	<P> <IMG WIDTH=466 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath62356" SRC="img982.gif"  ><P>	must contain every integer between 0 and <I>M</I>-1.	This second property ensures that the probe sequence	eventually probes <em>every possible array position</em>.<P> </DL><BR> <HR><UL> <LI> <A NAME="tex2html3942" HREF="page239.html#SECTION008610000000000000000">Linear Probing</A><LI> <A NAME="tex2html3943" HREF="page240.html#SECTION008620000000000000000">Quadratic Probing</A><LI> <A NAME="tex2html3944" HREF="page241.html#SECTION008630000000000000000">Double Hashing</A><LI> <A NAME="tex2html3945" HREF="page242.html#SECTION008640000000000000000">Implementation</A><LI> <A NAME="tex2html3946" HREF="page247.html#SECTION008650000000000000000">Average Case Analysis</A></UL><HR><A NAME="tex2html3939" HREF="page239.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3937" HREF="page205.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3931" HREF="page237.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html3941" 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 &#169; 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 + -
显示快捷键?