(@problem 1)
;; Below is the start of a data defini9on called Course that represents limited
;; informa9on about UBC courses. Below there are only two example data.
;; Please complete this defini9on by adding constants C110, C213, C313 and C317
;; which are representa9ons of the descendent tree for 110, 213, 313 and 317.
;; You can find the informa9on you need at
;; hIps://cs110.students.cs.ubc.ca/psets/pset-06-image.png
;;
;; NOTE 1: Use the informa9on in the image above, rather than any other source.
;; We are significantly simplying the informa9on.
;;
;; NOTE 2: Do this very carefully, the autograder wants to see correct results
;; from the func9ons you design to operate on this data.
;;
;; NOTE 3: The tree you will make for C110 will be a bit odd because 210 has 110
;; as a pre-req, and both 213 and 221 have 210 as a pre-req, and313 has
;; 213 AND 221 as a pre-req, and 317 has 213 AND 221 as a pre-req. As a
;; result, 313 and 317 will both show up twice in your descendent tree
; for C110. This is okay for this problem set.
;; NOTE 4: Expect this step of the problem set to take you some 9me.
(@htdd Course ListOfCourse)
(define-struct course (number credits dependents))
;; Course is (make-course Natural Natural ListOfCourse)
;; interp. a course with a course number,
;; the number of credits the course is worth, and a
;; list of courses that list this course as a direct pre-requisite
;; ListOfCourse is one of:
;; - empty
;; - (cons Course ListOfCourse)
;; interp. a list of courses
(define LOC0 empty)
(define C322 (make-course 322 3 LOC0))
(define C320 (make-course 320 3 LOC0))
(define C319 (make-course 319 4 LOC0))
(define C317 (make-course 317 3 LOC0))
(define C314 (make-course 314 3 LOC0))
(define C313 (make-course 313 3 LOC0))
(define C312 (make-course 312 3 LOC0))
(define C311 (make-course 311 3 LOC0))
, (define LOC1 (list C319))
(define C310 (make-course 310 4 LOC1))
(define C304 (make-course 304 3 LOC0))
(define C302 (make-course 302 3 LOC0))
(define C303 (make-course 303 3 LOC0))
(define LOC2 (list C304 C313 C314 C317 C320 C322))
(define C221 (make-course 221 4 LOC2))
(define LOC3 (list C313 C317))
(define C213 (make-course 213 4 LOC3))
(define LOC4 (list C213 C221 C310 C311 C312))
(define C210 (make-course 210 4 LOC4))
(define C203 (make-course 203 3 LOC0))
(define C189 (make-course 189 1 LOC0))
(define LOC5 (list C189 C203 C210 C302 C303))
(define C110 (make-course 110 4 LOC5))
(define C100 (make-course 100 3 LOC0))
(define (fn-for-course c)
(... (course-number c)
(course-credits c)
(fn-for-loc (course-dependents c))))
(define (fn-for-loc loc)
(cond [(empty? loc) (...)]
[else
(... (fn-for-course (first loc))
(fn-for-loc (rest loc)))]))
(@problem 2)
;;
;; Design a func9on that produces the list of all the course numbers in the
;; course's tree including the given course's number.
;;
;; Below is the start of a data defini9on called Course that represents limited
;; informa9on about UBC courses. Below there are only two example data.
;; Please complete this defini9on by adding constants C110, C213, C313 and C317
;; which are representa9ons of the descendent tree for 110, 213, 313 and 317.
;; You can find the informa9on you need at
;; hIps://cs110.students.cs.ubc.ca/psets/pset-06-image.png
;;
;; NOTE 1: Use the informa9on in the image above, rather than any other source.
;; We are significantly simplying the informa9on.
;;
;; NOTE 2: Do this very carefully, the autograder wants to see correct results
;; from the func9ons you design to operate on this data.
;;
;; NOTE 3: The tree you will make for C110 will be a bit odd because 210 has 110
;; as a pre-req, and both 213 and 221 have 210 as a pre-req, and313 has
;; 213 AND 221 as a pre-req, and 317 has 213 AND 221 as a pre-req. As a
;; result, 313 and 317 will both show up twice in your descendent tree
; for C110. This is okay for this problem set.
;; NOTE 4: Expect this step of the problem set to take you some 9me.
(@htdd Course ListOfCourse)
(define-struct course (number credits dependents))
;; Course is (make-course Natural Natural ListOfCourse)
;; interp. a course with a course number,
;; the number of credits the course is worth, and a
;; list of courses that list this course as a direct pre-requisite
;; ListOfCourse is one of:
;; - empty
;; - (cons Course ListOfCourse)
;; interp. a list of courses
(define LOC0 empty)
(define C322 (make-course 322 3 LOC0))
(define C320 (make-course 320 3 LOC0))
(define C319 (make-course 319 4 LOC0))
(define C317 (make-course 317 3 LOC0))
(define C314 (make-course 314 3 LOC0))
(define C313 (make-course 313 3 LOC0))
(define C312 (make-course 312 3 LOC0))
(define C311 (make-course 311 3 LOC0))
, (define LOC1 (list C319))
(define C310 (make-course 310 4 LOC1))
(define C304 (make-course 304 3 LOC0))
(define C302 (make-course 302 3 LOC0))
(define C303 (make-course 303 3 LOC0))
(define LOC2 (list C304 C313 C314 C317 C320 C322))
(define C221 (make-course 221 4 LOC2))
(define LOC3 (list C313 C317))
(define C213 (make-course 213 4 LOC3))
(define LOC4 (list C213 C221 C310 C311 C312))
(define C210 (make-course 210 4 LOC4))
(define C203 (make-course 203 3 LOC0))
(define C189 (make-course 189 1 LOC0))
(define LOC5 (list C189 C203 C210 C302 C303))
(define C110 (make-course 110 4 LOC5))
(define C100 (make-course 100 3 LOC0))
(define (fn-for-course c)
(... (course-number c)
(course-credits c)
(fn-for-loc (course-dependents c))))
(define (fn-for-loc loc)
(cond [(empty? loc) (...)]
[else
(... (fn-for-course (first loc))
(fn-for-loc (rest loc)))]))
(@problem 2)
;;
;; Design a func9on that produces the list of all the course numbers in the
;; course's tree including the given course's number.
;;