CPSC 110 GRADED PROBLEM SET 10 2022/2023 RATED 100%
CPSC 110 GRADED PROBLEM SET 10 2022/2023 RATED 100% ;; DO NOT PUT ANY PERSONALLY IDENTIFYING INFORMATION IN THIS FILE. ;; Problem Set 10 (THIS IS A ONE-PHASE PEER GRADED PROBLEM) ; PROBLEM 1: ; ; Recall the prefix spelling trees from Midterm 2. ; ; . ; ; ; ; Design a function called count-odds that takes a prefix spelling tree ; and determines how many odd-length words are contained in it. ; Use a lost-context accumulator to design this function NO MARKS WILL BE GIVEN ; for a solution that does not use a lost-context accumulator. ; ; We have provided the data definition for prefix trees below. (define-struct pt (l f? subs)) ;; PrefixTree is (make-pt String Boolean (listof PrefixTree)) ;; interp. a prefix spelling tree. The sequence of letters up to and including ;; a given node are a legal word if f? is true, not legal otherwise. (define PT0 (make-pt "K" true empty)) (define PTT (make-pt "t" false (list (make-pt "o" true (list (make-pt "o" true (list (make-pt "k" true empty))) (make-pt "t" true empty) (make-pt "l" false (list (make-pt "l" true empty))) (make-pt "u" false (list (make-pt "c" false (list (make-pt "h" true empty))))))) (make-pt "i" false (list (make-pt "n" true empty)))))) (define LOPT0 (list (make-pt "o" true empty) (make-pt "t" true empty)))
Geschreven voor
- Instelling
- Liberty University
- Vak
- CPSC 110
Documentinformatie
- Geüpload op
- 13 oktober 2023
- Aantal pagina's
- 6
- Geschreven in
- 2023/2024
- Type
- Tentamen (uitwerkingen)
- Bevat
- Vragen en antwoorden
Onderwerpen
-
cpsc 110 graded problem set rated 100