📄 page310.html
字号:
<HTML><HEAD><TITLE>Implementing Search Trees</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="tex2html4770" HREF="page311.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4768" HREF="page298.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4762" HREF="page309.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4772" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION0010400000000000000000">Implementing Search Trees</A></H1><P>Since search trees are designed to support efficient searching,it is only appropriate that they extendthe <tt>SearchableContainer</tt> class.Recall from Section <A HREF="page126.html#secadtssrchcont"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> that the searchable containerclass includes the operations <tt>__contains__</tt>, <tt>find</tt>,<tt>insert</tt>, and <tt>withdraw</tt>.<P><P><A NAME="18609"> </A><A NAME="figclasses6"> </A> <IMG WIDTH=575 HEIGHT=257 ALIGN=BOTTOM ALT="figure18605" SRC="img1232.gif" ><BR><STRONG>Figure:</STRONG> Object class hierarchy<BR><P><P>Program <A HREF="page310.html#progsearchTreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> defines the <tt>SearchTree</tt> class.The abstract <tt>SearchTree</tt> class extends the abstract <tt>Tree</tt> classintroduced in Program <A HREF="page267.html#progtreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> as well as theand the abstract <tt>SearchableContainer</tt> classdefined in Program <A HREF="page126.html#progsearchableContainera"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<P><P><A NAME="18786"> </A><A NAME="progsearchTreea"> </A> <IMG WIDTH=575 HEIGHT=355 ALIGN=BOTTOM ALT="program18619" SRC="img1233.gif" ><BR><STRONG>Program:</STRONG> Abstract <tt>SearchTree</tt> class <tt>min</tt> and <tt>max</tt> properties.<BR><P><P>In addition, two properties are defined--<tt>min</tt> and <tt>max</tt>.The <tt>min</tt> property uses the <tt>getMin</tt> methodto return the object containedin the search tree having the smallest key.Similarly, the <tt>max</tt> uses the <tt>getMax</tt> methodto returns the contained object having the largest key.<P><BR> <HR><UL> <LI> <A NAME="tex2html4773" HREF="page311.html#SECTION0010410000000000000000">Binary Search Trees</A><LI> <A NAME="tex2html4774" HREF="page315.html#SECTION0010420000000000000000">Inserting Items in a Binary Search Tree</A><LI> <A NAME="tex2html4775" HREF="page317.html#SECTION0010430000000000000000">Removing Items from a Binary Search Tree</A></UL><HR><A NAME="tex2html4770" HREF="page311.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4768" HREF="page298.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4762" HREF="page309.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4772" 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -