CS202 -- Lab 9 (Spring 2024)


Inspiration

This is the companion lab to the hash table lab earlier in the semester, except now you will use a binary tree to represent the data. This basically is how you would implement an STL map (or a dictionary in Python, since a few of you seemed to know about them in class)

There are some wrinkles here, namely you ** must ** correctly implement the assignment operator and copy constructor, both of which will "balance" the tree. This is per my discussion with the TAs in prior semesters in that most of the issues you have been having deal with stack vs. heap allocation, and pointers, and this assignment hits both pretty hard.

Originial version here: http://web.eecs.utk.edu/~jplank/plank/classes/cs202/Labs/LabA

The program that you should write

Your job is detailed in the section entitled "Your Lab" in the historical lecture notes on trees and binary search trees. You are to submit the file src/bstree_lab.cpp. You are not allowed to modify include/bstree.hpp or src/bstree_notes.cpp.

Testing and Grading for Correctness

The gradescripts work in the following way:

Gradescripts 1-10 test Depth().
Gradescripts 11-20 test Height().
Gradescripts 21-30 test Ordered_Keys().
Gradescripts 31-40 test the assignment overload.
Gradescripts 41-50 test the copy constructor.

The remaining gradescripts test everything.