page301.html
来自「Data Structures And Algorithms With Obje」· HTML 代码 · 共 50 行
HTML
50 行
<HTML><HEAD><TITLE>Binary 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="tex2html4669" HREF="page302.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4667" HREF="page299.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4663" HREF="page300.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4671" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION0010120000000000000000">Binary Search Trees</A></H2><P>Just as the binary tree is an important category of <I>N</I>-ary trees,the <em>binary search tree</em><A NAME=18067> </A>is an important category of <I>M</I>-way search trees.<P><BLOCKQUOTE> <b>Definition (Binary Search Tree)</b><A NAME="defnbst"> </A>A <em>binary search tree</em><A NAME=18072> </A><A NAME=18073> </A> <I>T</I> is a finite set of keys.Either the set is empty, <IMG WIDTH=40 HEIGHT=27 ALIGN=MIDDLE ALT="tex2html_wrap_inline62991" SRC="img1064.gif" >;or the set consists of a root <I>r</I>and exactly two binary search trees <IMG WIDTH=18 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63147" SRC="img1085.gif" > and <IMG WIDTH=18 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63149" SRC="img1086.gif" >, <IMG WIDTH=108 HEIGHT=24 ALIGN=MIDDLE ALT="tex2html_wrap_inline63151" SRC="img1087.gif" >,such that the following properties are satisfied:<OL><LI> All the keys contained in left subtree, <IMG WIDTH=18 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63147" SRC="img1085.gif" >, are less than <I>r</I>.<LI> All the keys contained in the right subtree, <IMG WIDTH=18 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline63149" SRC="img1086.gif" >, are greater than <I>r</I>.</OL></BLOCKQUOTE><P>Figure <A HREF="page301.html#figtree12"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> shows an example of a binary search tree.In this case, since the nodes of the tree carry alphabeticrather than numeric keys,the ordering of the keys is alphabetic.That is, all the keys in the left subtree of a given nodeprecede alphabetically the root of the that node,and all the keys in the right subtree of a given nodefollow alphabetically the root of that node.The empty trees are shown explicitly as boxes in Figure <A HREF="page301.html#figtree12"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.However, in order to simplify the graphical representation,the empty trees are often omitted from the diagrams.<P><P><A NAME="18182"> </A><A NAME="figtree12"> </A> <IMG WIDTH=575 HEIGHT=222 ALIGN=BOTTOM ALT="figure18079" SRC="img1180.gif" ><BR><STRONG>Figure:</STRONG> A binary search tree.<BR><P><HR><A NAME="tex2html4669" HREF="page302.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4667" HREF="page299.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4663" HREF="page300.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4671" 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 + =
减小字号Ctrl + -
显示快捷键?