📄 page268.html
字号:
<HTML><HEAD><TITLE>Tree Traversals</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="tex2html4292" HREF="page269.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4290" HREF="page267.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4284" HREF="page267.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4294" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H2><A NAME="SECTION009610000000000000000">Tree Traversals</A></H2><A NAME="sectreesimpltrav"> </A><P>The abstract <tt>Tree</tt> class also provides default implementationsfor two methods called <tt>depthFirstTraversal</tt>and <tt>breadthFirstTraversal</tt>.These methods are like the <tt>accept</tt>method of the container class (see Section <A HREF="page118.html#secadtscontainers"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>).Both of these methods perform a traversal.That is, all the nodes of the tree are visited systematically.Both of these implementations access abstract properties,such as <tt>key</tt>,and call abstract methods,such as and <tt>getSubtree</tt>.In effect, they are <em>abstract algorithms</em><A NAME=15564> </A>.An abstract algorithm describes behavior in the absence of implementation!<P><BR> <HR><UL> <LI> <A NAME="tex2html4295" HREF="page269.html#SECTION009611000000000000000">Depth-First Traversal</A><LI> <A NAME="tex2html4296" HREF="page270.html#SECTION009612000000000000000">Preorder, Inorder, and Postorder Traversals</A><LI> <A NAME="tex2html4297" HREF="page271.html#SECTION009613000000000000000">Breadth-First Traversal</A><LI> <A NAME="tex2html4298" HREF="page272.html#SECTION009614000000000000000"><tt>accept</tt> Method</A></UL><HR><A NAME="tex2html4292" HREF="page269.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4290" HREF="page267.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4284" HREF="page267.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4294" 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 + -