COM1201 Spring 1997 Professor Fell QUIZ 7

1( 8 points ) For the tree shown below, list the order in which the nodes are visited in:
a. preorder            
 

b. postorder
 

c. inorder
 

d. level order
 

2. (6 points) Write a recursive C++ function that inputs, as an argument, a binary tree (i.e. a pointer to the root node) and outputs the number of nodes in the tree that are right children. (In the tree above, D, E, G, H, I are right children.)

3. (6 points) For each of the expresions below, draw the corresponding expression tree and evaluate the expression.

a. (preorder expression) + * 3 - + 9 2 1 5

b. (postorder expression) 7 5 - 6 + 5 2 * 9 4 - * +


Last Updated: May 18, 1997 2:32 pm by

Harriet Fell
College of Computer Science, Northeastern University
360 Huntington Avenue #161CN,
Boston, MA 02115
Internet: fell@ccs.neu.edu
Phone: (617) 373-2198 / Fax: (617) 373-5121
The URL for this document is: http://www.ccs.neu.edu/home/fell/COM1101/QUIZ/Q7/quiz7.html