page332.html

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

HTML
46
字号
<HTML><HEAD><TITLE>Implementation</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="tex2html5023" HREF="page333.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html5021" HREF="page331.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html5015" HREF="page331.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html5025" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H3><A NAME="SECTION0010611000000000000000">Implementation</A></H3><P>Program&nbsp;<A HREF="page332.html#progmWayTreea"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> introduces the <tt>MWayTree</tt> class.The <tt>MWayTree</tt> class extends the abstract <tt>SearchTree</tt> classintroduced in Program&nbsp;<A HREF="page310.html#progsearchTreea"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.The two instance attributes, <tt>_key</tt> and <tt>_subtree</tt>,correspond to the components of a node shown in Figure&nbsp;<A HREF="page331.html#figmway"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.(Remember, the <tt>_count</tt> instance attribute is inherited from theabstract <tt>Container</tt> base class introduced inProgram&nbsp;<A HREF="page119.html#progcontainera"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>).<P><P><A NAME="21028">&#160;</A><A NAME="progmWayTreea">&#160;</A> <IMG WIDTH=575 HEIGHT=294 ALIGN=BOTTOM ALT="program20822" SRC="img1299.gif"  ><BR><STRONG>Program:</STRONG> <tt>MWayTree</tt> class <tt>__init__</tt> method and <tt>m</tt> property<BR><P><P>The first instance attribute, <tt>_key</tt>,is an array used to record the keys contained in the node.The second instance attribute, <tt>_subtree</tt>,is an array of <tt>MWayTree</tt> instanceswhich are the subtrees of the given node.<P>The inherited <tt>_count</tt> instance attributekeeps track of the number of keys contained in the node.Recall, a node which contains  <IMG WIDTH=46 HEIGHT=9 ALIGN=BOTTOM ALT="tex2html_wrap_inline64737" SRC="img1300.gif"  > keyshas  <IMG WIDTH=74 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline64739" SRC="img1301.gif"  > subtrees.We have chosen to keep track of the number of keys of a noderather than the number of subtrees because it simplifiesthe coding of the algorithms by eliminating some of the special cases.<P><HR><A NAME="tex2html5023" HREF="page333.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html5021" HREF="page331.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html5015" HREF="page331.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html5025" 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 + -
显示快捷键?