📄 page297.html
字号:
<HTML><HEAD><TITLE>Projects</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="tex2html4615" HREF="page298.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4613" HREF="page251.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4609" HREF="page296.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4617" HREF="page611.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="../icons/index_motif.gif"></A> <BR><HR><H1><A NAME="SECTION009800000000000000000">Projects</A></H1><P><OL><LI> Devise an algorithm to compute the height of a tree. Write an implementation of your algorithm as the <tt>getHeight</tt> method of the abstract <tt>Tree</tt> class introduced in Program <A HREF="page267.html#progtreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<LI> Devise an algorithm to count the number of internal nodes in a tree. Write an implementation of your algorithm as the <tt>getCount</tt> method of the <tt>AbstractTree</tt> class introduced in Program <A HREF="page267.html#progtreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<LI> Devise an algorithm to count the number of leaves in a tree. Write an implementation of your algorithm as a method of the <tt>AbstractTree</tt> class introduced in Program <A HREF="page267.html#progtreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<LI> Devise an abstract (generic) algorithm to compare trees. (See Exercise <A HREF="page296.html#exercisetreescompare"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>). Write an implementation of your algorithm as the <tt>_compareTo</tt> method of the abstract <tt>Tree</tt> class introduced in Program <A HREF="page267.html#progtreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.<LI> The <tt>Iterator</tt> class introduced in Program <A HREF="page273.html#progtreee"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> does a <em>preorder</em> traversal of a tree. <OL><LI> Write an iterator class that does a <em>postorder</em> traversal.<LI> Write an iterator class that does a <em>breadth-first</em> traversal.<LI> Write an iterator class that does an <em>inorder</em> traversal. (In this case, assume that the tree is a <tt>BinaryTree</tt>). </OL><LI> <A NAME="projecttreesgentree"> </A> Complete the <tt>GeneralTree</tt> class introduced in Program <A HREF="page276.html#proggeneralTreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> by providing suitable definitions for the following operations: <tt>getIsEmpty</tt>, <tt>getIsLeaf</tt>, <tt>getDegree</tt>, and <tt>_compareTo</tt>. Write a test program and test your implementation.<LI> Complete the <tt>NaryTree</tt> class introduced in Program <A HREF="page281.html#prognaryTreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> by providing suitable definitions for the following operations: <tt>getIsLeaf</tt>, <tt>getDegree</tt>, and <tt>_compareTo</tt>. Write a test program and test your implementation.<LI> <A NAME="projecttreesbintree"> </A> Complete the <tt>BinaryTree</tt> class introduced in Program <A HREF="page287.html#progbinaryTreea"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A> by providing suitable definitions for the following operations: <tt>getIsEmpty</tt>, <tt>getIsLeaf</tt>, <tt>getDegree</tt>, <tt>getKey</tt>, <tt>attachKey</tt>, <tt>detachKey</tt>, <tt>attachLeft</tt>, <tt>detachLeft</tt>, <tt>attachRight</tt>, <tt>detachRight</tt>, and <tt>getSubtree</tt>. Write a test program and test your implementation.<LI> Write a visitor that draws a picture of a tree on the screen.<LI> Design and implement an algorithm that constructs an expression tree from an <em>infix</em> expression such as <P> <IMG WIDTH=297 HEIGHT=13 ALIGN=BOTTOM ALT="displaymath63687" SRC="img1167.gif" ><P> <b>Hint</b>: See Project <A HREF="page167.html#projectstacksconvert"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/cross_ref_motif.gif"></A>.</OL><P><HR><A NAME="tex2html4615" HREF="page298.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="../icons/next_motif.gif"></A> <A NAME="tex2html4613" HREF="page251.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="../icons/up_motif.gif"></A> <A NAME="tex2html4609" HREF="page296.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="../icons/previous_motif.gif"></A> <A NAME="tex2html4617" 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 + -