Read the expectations on homework. Also, read Section 14.2 in the text.
number-in-stock
which consumes a binary search tree and a part number
and returns a number. The number returned is the number of items in stock for the given part. You may assume the part number exists in the tree. Your function should be
written efficiently, such that it examines as few records as is
necessary.
restock
which consumes a binary search
tree, a part number, and the number of additional parts, and produces a
binary search tree. The tree that is produced is the same as the original
except that the number of parts in stock for the given item has been
increased by the number of additional parts. You may assume that the
given part number exists in the tree. Your function should be
written efficiently, such that it examines as few records as is
necessary.
list-all-parts
, which consumes a binary
search tree and produces a list of numbers.
The function produces a list of the part numbers of every item in the tree,
such that the list of numbers is in ascending numeric order.
(Hint: take advantage of what you know about binary search trees
to lead you to a way of constructing a sorted list. You do not need to (nor should you) design a
separate sorting function.)
add-part
. The function consumes a
binary search tree, a part number, a description of the part, the unit price, and the number of parts in stock and adds a
new record with the given information to the binary search tree. Make sure
that the tree that is produced is a binary search tree. You may assume that the
part number 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.) Your function should be
written efficiently, such that it examines as few records as is
necessary.
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 homework files. Make sure both partners' names and wpi login names appear in a comment at the top of the file.