A book publisher keeps track of its books by storing the information about each book in a binary search tree ordered on the ISBN number. For each book, in addition to the ISBN number (and the left and right branches in the tree), the following information is stored: the title, author, year of publication, cost, and number of copies sold.
increase-price
that consumes a binary
search tree of books and a number representing a per cent increase and produces
a binary search tree the same as the original except that the cost of each book
in the tree has been increased by the given percentage.
copies-sold
which consumes a binary search tree and an ISBN
number, and returns the number of copies sold for the book with the given ISBN.
If a book with the given ISBN doesn't exist in the tree, the function
should return -1.
Your function should be
written efficiently, such that it performs as few comparisons as is
necessary to find the correct ISBN number in the tree.
add-new-book
. The function consumes a
binary search tree, an ISBN, title, author, and price and adds a new book with the
given ISBN, title, author, and price to the binary search tree. The new book has a
publication date of 2010 and has no copies sold.
Make sure that the tree that is produced is a binary search tree. You may assume that the ISBN number of the book to be added does not already exist in the given tree. (Hint: new records are always added at the "leaf" end of the tree; records are never inserted into the middle layers of a binary search tree.)
Using web-based turnin, turn in a single file containing all code and documentation for this assignment. Name your file according to the naming conventions for files. Make sure both partners' names and wpi login names appear in a comment at the top of the file.