page339.html

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

HTML
42
字号
<HTML><HEAD><TITLE>Removing Items from an M-Way Search Tree</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="tex2html5096" HREF="page340.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html5094" HREF="page330.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html5090" HREF="page338.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html5098" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION0010640000000000000000">Removing Items from an <I>M</I>-Way Search Tree</A></H2><P>The algorithm for removing items from an <I>M</I>-way search treefollows directly from the algorithm for removing items froma binary search tree given in Section&nbsp;<A HREF="page317.html#secsrchtreebstout"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.The basic idea is that the item to be deleted is pushed down the treefrom its initial position to a node from which it can be easily deleted.Clearly, items are easily deleted from leaf nodes.In addition, consider an internal node of an <I>M</I>-way search tree of the form<P> <IMG WIDTH=416 HEIGHT=16 ALIGN=BOTTOM ALT="displaymath64923" SRC="img1326.gif"  ><P>If both  <IMG WIDTH=29 HEIGHT=20 ALIGN=MIDDLE ALT="tex2html_wrap_inline63735" SRC="img1176.gif"  > and  <IMG WIDTH=14 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62823" SRC="img1051.gif"  > are empty trees,then the key  <IMG WIDTH=12 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63737" SRC="img1177.gif"  > can be deleted from <I>T</I>by removing both  <IMG WIDTH=12 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63737" SRC="img1177.gif"  > and  <IMG WIDTH=14 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62823" SRC="img1051.gif"  >, say.If  <IMG WIDTH=29 HEIGHT=20 ALIGN=MIDDLE ALT="tex2html_wrap_inline63735" SRC="img1176.gif"  > is non-empty,  <IMG WIDTH=12 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63737" SRC="img1177.gif"  > can be pushed down the tree byswapping it with the largest key in  <IMG WIDTH=29 HEIGHT=20 ALIGN=MIDDLE ALT="tex2html_wrap_inline63735" SRC="img1176.gif"  >;and if  <IMG WIDTH=14 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62823" SRC="img1051.gif"  > is non-empty,  <IMG WIDTH=12 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63737" SRC="img1177.gif"  > can be pushed down the tree byswapping it with the smallest key in  <IMG WIDTH=14 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62823" SRC="img1051.gif"  >.<P>Program&nbsp;<A HREF="page339.html#progmWayTreef"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> gives the code for the <tt>withdraw</tt>method of the <tt>MWayTree</tt> class.The general form of the algorithm follows that of the <tt>withdraw</tt>method for the <tt>BinarySearchTree</tt> class (Program&nbsp;<A HREF="page318.html#progbinarySearchTreed"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>).<P><P><A NAME="21045">&#160;</A><A NAME="progmWayTreef">&#160;</A> <IMG WIDTH=575 HEIGHT=581 ALIGN=BOTTOM ALT="program20972" SRC="img1327.gif"  ><BR><STRONG>Program:</STRONG> <tt>MWayTree</tt> class <tt>withdraw</tt> method.<BR><P><HR><A NAME="tex2html5096" HREF="page340.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html5094" HREF="page330.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html5090" HREF="page338.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html5098" 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 + -
显示快捷键?