Read the expectations on homework.
Make sure you name your structs and functions exactly the same as the names given in the problems below. Otherwise, our auto-tester won't work and you'll lose points on the assignment.
Copy/paste your work from Lab 4 (Problems 1 - 5) into your HW4 file and continue with the remaining problems in the assignment.
;; a BST is one of ;; false ;; CourseNode ;; a CourseNode is a (make-coursenode Number String String ListOfStudent BST BST) (define-struct coursenode (course-id title instructor students left right))(Course ID's would be something like 92.101, where 92 represents the department, and 101 identifies a course in department 92. The course ID is used as the key value in the BST.) Write the interpretation for a BST (including the invariant).
any-taught-by?
which consumes a binary search tree and the name of an instructor,
and produces true if any of the courses in the course database are taught by the given instructor.
drop-student
that consumes a binary search tree, a course number, and the email address of a student, and produces a binary search tree.
The function drops (removes) the student with the given email address from the list of students enrolled in the given course. (If there is no enrolled student with the given email address, the tree that is returned by the function is the same as the original.) Your function should be written efficiently, taking advantage of the binary search tree invariant to minimize the number of comparisons needed to find the course with the correct course number. You may assume that the given course number exists in the tree.
list-titles-in-order-by-coursenum
.
The function consumes a
binary search tree and produces a list of the titles of the courses, sorted in order by ascending course number.
(Hint: you don't have to write a sorting algorithm. Use what you know
about the order of items in a binary search tree to help you. You will
need to use the built-in function append
for this problem.)
add-course
. The function consumes a
binary search tree, a course number, a course title, and the name of the instructor, and creates a binary search tree the same as the original except that a
new course with the given information has been added to the tree. The course is created with an empty enrollment list. Make sure
that the tree that is produced is a binary search tree. You may assume that the
course number does not already exist in the given tree. (Hint: new items are
always added at the "leaf" end of the tree. Items are never inserted into
the middle layers of a binary search tree.)
Submit your .rkt
file to InstructAssist. 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.