page224.html

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

HTML
51
字号
<HTML><HEAD><TITLE>Separate Chaining</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="tex2html3782" HREF="page225.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3780" HREF="page223.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3774" HREF="page223.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html3784" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION008410000000000000000">Separate Chaining</A></H2><P>Figure&nbsp;<A HREF="page224.html#fighash1"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> shows a hash table that uses<em>separate chaining</em><A NAME=11060>&#160;</A>to resolve collisions.The hash table is implemented as an array of linked lists.To insert an item into the table,it is appended to one of the linked lists.The linked list to it is appended isdetermined by hashing that item.<P><P><A NAME="11265">&#160;</A><A NAME="fighash1">&#160;</A> <IMG WIDTH=575 HEIGHT=380 ALIGN=BOTTOM ALT="figure11061" SRC="img927.gif"  ><BR><STRONG>Figure:</STRONG> Hash table using separate chaining.<BR><P><P>Figure&nbsp;<A HREF="page224.html#fighash1"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> illustrates an example in whichthere are <I>M</I>=16 linked lists.The twelve character strings <tt>&quot;ett&quot;</tt>-<tt>&quot;tolv&quot;</tt>have been inserted into the table using the hashed valuesand in the order given in Table&nbsp;<A HREF="page220.html#tblhashingwords"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.Notice that in this example since <I>M</I>=16,the linked list is selected by the least significant four bitsof the hashed value given in Table&nbsp;<A HREF="page220.html#tblhashingwords"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.In effect,it is only the last letter of a string which determinesthe linked list in which that string appears.<P><BR> <HR><UL> <LI> <A NAME="tex2html3785" HREF="page225.html#SECTION008411000000000000000">Implementation</A><LI> <A NAME="tex2html3786" HREF="page226.html#SECTION008412000000000000000"><tt>__init__</tt>, <tt>__len__</tt> and <tt>purge</tt> Methods</A><LI> <A NAME="tex2html3787" HREF="page227.html#SECTION008413000000000000000">Inserting and Removing Items</A><LI> <A NAME="tex2html3788" HREF="page228.html#SECTION008414000000000000000">Finding an Item</A></UL><HR><A NAME="tex2html3782" HREF="page225.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html3780" HREF="page223.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html3774" HREF="page223.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html3784" 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 + -
显示快捷键?