page254.html

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

HTML
51
字号
<HTML><HEAD><TITLE>More Terminology</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="tex2html4129" HREF="page255.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4127" HREF="page252.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4121" HREF="page253.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html4131" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H3><A NAME="SECTION009102000000000000000">More Terminology</A></H3><P>Consider a tree <I>T</I> containing the set of nodes <I>R</I>as given by Definition&nbsp;<A HREF="page252.html#defntree"><IMG  ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<UL><LI>	The <em>level</em><A NAME=14476>&#160;</A>	or <em>depth</em><A NAME=14478>&#160;</A> of a node  <IMG WIDTH=44 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62855" SRC="img1056.gif"  >	in a tree <I>T</I> is the length of the unique path in <I>T</I>	from its root <I>r</I> to the node  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  >.	For example, the root of <I>T</I> is at level zero and	the roots of the subtrees are of <I>T</I> are at level one.<LI>	The <em>height of a node</em><A NAME=14480>&#160;</A>	 <IMG WIDTH=44 HEIGHT=22 ALIGN=MIDDLE ALT="tex2html_wrap_inline62855" SRC="img1056.gif"  > in a tree <I>T</I>	is the length of the longest path from node  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > to a leaf.	Therefore, the leaves are all at height zero.<LI>	The <em>height of a tree</em><A NAME=14482>&#160;</A><A NAME=14483>&#160;</A>	<I>T</I> is the height of its root node <I>r</I>.<LI>	Consider two nodes  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > and  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  > in a tree <I>T</I>.	The node  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > is an <em>ancestor</em><A NAME=14485>&#160;</A>	of the node  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  > if there exists a path in <I>T</I> from  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > to  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  >.	Notice that  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > and  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  > may be the same node.	That is, a node is its own ancestor.	However, the node  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  >	is a <em>proper ancestor</em><A NAME=14487>&#160;</A>	if there exists a path <I>p</I> in <I>T</I> from  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > to  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  >	such that the length of the path <I>p</I> is non-zero.<LI>	Similarly, node  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  > is a <em>descendant</em><A NAME=14489>&#160;</A>	of the node  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > if there exists a path in <I>T</I> from  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > to  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  >.	And since  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > and  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  > may be the same node,	a node is its own descendant.	The node  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  >	is a <em>proper descendant</em><A NAME=14491>&#160;</A>	if there exists a path <I>p</I> in <I>T</I> from  <IMG WIDTH=11 HEIGHT=14 ALIGN=MIDDLE ALT="tex2html_wrap_inline62821" SRC="img1050.gif"  > to  <IMG WIDTH=13 HEIGHT=15 ALIGN=MIDDLE ALT="tex2html_wrap_inline62841" SRC="img1053.gif"  >	such that the length of the path <I>p</I> is non-zero.</UL><HR><A NAME="tex2html4129" HREF="page255.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4127" HREF="page252.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4121" HREF="page253.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A>  <A NAME="tex2html4131" 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 + -
显示快捷键?