Comp 121 Introduction to Data Structures.
Spring 2000Programming Assignment 3 -- Due March 28, 2000
Objective: To gain experience in implementing binary trees.
Goal. To implement the binary search tree ADT as an object template in C++. To use this ADT as the basis of a sorting program.
The binary search tree (bstree) abstract data type is specified as follows [p. 490 of your text]:
AbstractDataType bstree{
Instances: binary trees; each node has an element; all elements are distinct; elements in the left subtree of any node are smaller than the element in the node; elements in the right subtree are larger.
Operations:
create( ):
Create an empty binary search treedestroy( )
: Erase a binary search treefind(k):
Return true if the binary search tree contains the element k; false otherwise.printSort( ):
Output all elements in the binary search tree in ascending orderdelete(k):
Delete the element k from the binary search tree.Insert(k):
Insert the element k into the binary search tree}
You are to implement this ADT in the C++ programming language. Feel free to refer to the code in the text for help however, your work should be your own, and not a copy of the text code.
Sorting. In a prior assignment (Programming Assignment 1), you implemented a program for sorting a number of points with the help of a priority-queue. You are to now compare the performance of that sorting program with the following:
Given a file of elements that are to be sorted, we can insert these elements successively into a binary search tree, and then call printSort( ) to print out all the elements in the tree in sorted order.
You will be required to collect timing information on the performance of both your sorting programs the one using priority queues, and the current one in sorting certain data-sets that will be made available on the class web-page prior to the assignment due-date. These data-sets will be in the same format as in Programming Assignment 1: you will be given the points to be sorted in a file, which contains the number of points in the file followed by a pair of coordinates for each point.
Rules for submitting this program:
All of the above should be placed in an envelope with your name and student-ID on the outside, and submitted at the beginning of class on the due date. Submissions will not be accepted after 10 minutes have elapsed from the start of class no late submissions will be accepted without documented reasons.