Project 3: Traveller of Trees

Educational Objectives: On successful completion of this assignment, the student should be able to

Operational Objectives: implement three binary tree iterator types: BinaryTreePostorderIterator<T>, BinaryTreePreorderIterator<T>, and BinaryTreeLevelorderIterator<T> as declared in the file tbt.h. Also implement the method TBinaryTree<T>::Dump(std::ostream& os).

Deliverables: Two files:

tbt3.cpp // contains implementation of Dump(std::ostream&)
tbt5.cpp // contains implementations of preorder, postorder, and levelorder iterators

Background

Required background knowledge is reviewed in Trees 1 , Trees 2 , Trees 3

The binary tree class and its associated navigator class, iterator classes, and functions are all defined/prototyped in the header file tbt.h. Slave files are used to house implementations of various components of the TBinaryTree. The files in the package are as follows:

tbt.h        // class definitions and function/operator prototypes
tbt1.cpp     // implements TBinaryTree, TBinaryTreeNavigator, and all stand-alone operators
tbt2.cpp     // implements function int Load(TBinaryTree<T>&, const char*)
tbt3.cpp     // implements method void TBinaryTree<T>::Dump(std::ostream&)
tbt4.cpp     // implements class InorderIterator
tbt5.cpp     // implements classes PreorderIterator, PostorderIterator, LevelorderIterator,
tbt6.cpp     // implements TBinaryTree<T> rotation methods

(Recall that a "slave" file is one that is included into its master file with a #include<> directive. Slave files should not define a namespace or #include their associated header file, otherwise an infinite loop of #includes is created. The effect on client programs is that only the master header file is #included into source files. A slave file makes no sense to the compiler by itself. A slave file only makes sense when considerd a logical part of its master file.)

Procedural Requirements:

  1. Implement the 1-parameter dump method, as prototyped in LIB/tcpp/tbt.h. Place this implementation in file tbt3.cpp.
  2. Complete the implementations of the three alternative iterator types (preorder, postorder, and levelorder) for binary trees, as defined in LIB/tcpp/tbt.h. Place these implementations in file tbt5.cpp.
  3. Test your implementations thoroughly.
  4. Turn in two files tbt3.cpp tbt5.cpp using the proj3submit.sh submit script.

    Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit projects. If you do not receive the second confirmation with the contents of your project, there has been a malfunction.

Technical Requirements and Specifications

  1. Implement the three iterator classes as specified in tbt.h, starting with LIB/proj3/tbt5.partial.
  2. Use iteration-based depth-first search to implement PostorderIterator.
  3. Use stack-based depth-first search to implement PreorderIterator.
  4. Use queue-based breadth-first search to implement LevelorderIterator.
  5. Note that PreorderIterator and LevelorderIterator are somewhat curtailed forward iterators, while PostorderIterator is a fully functional bidirectional iterator.
  6. Implement the 1-parameter Dump() method as prototyped in tbt.h and demonstrated in the distributed executables, beginning from the file LIB/proj3/tbt3.partial.

Hints