Homework 7

Computer Architecture I ShanghaiTech University
HW6 HW7

Instructions

In this homework you will write a library for binary search trees in C++. This will involve templates, iterators and const correctness. It is highly recommended that you review these topics before implementing the library.

Handout: hw7.tar.gz Update: made treeNode private in bintree.h!

Submission

You will have to check in two files:

API Specifications

The header file will have Fill in this part sections and other instructions that you will have to fill in by yourself. From binTree we will only call functions already given in the header files - for the iterators you have to implement the required functions.

binTree Class

binTree contains the necessary attributes and methods for a binary search tree. Feel free to add in more if necessary. The methods are defined below:

treeNode Class

Fill in this class with attributes and methods for a node in a binary search tree.

preorder_iterator Class

Fill in this class for an iterator for preorder traversal. Refer to STL iterators for the necessary implementations.

inorder_iterator Class

Fill in this class for an iterator for inorder traversal. Refer to STL iterators for the necessary implementations.

postorder_iterator Class

Fill in this class for an iterator for postorder traversal. Refer to STL iterators for the necessary implementations.

Const Correctness

You are required to implement your class such that it offers the programmer the possibility to program using the const keyword. You'll have to add and implement iterator classes and functions that are const in order achieve that. The new classes will be preceded with "const_" (e.g. in stl it would be std::vector‹int›::const_iterator). The bintree functions do not change in name.

Additional Requirements

Checkout

Checkout the homework from gradebot.

$ git clone metastasis@gradebot.org:user/{username}/3/11

Check in

To check in, make a commit and execute

$ git push origin master
Gradebot will open soon...