#### Lab 7: Exam Preparation

Important Note Whenever we say to "design a function", we mean that you need to follow the design recipe. Any other time that you write a function in this class, you also need to follow the design recipe.

##### Structures and functions

Exercise 1 Develop a data and structure definition for a Triple, which holds three numbers.

Exercise 2 Write the template for processing a Triple.

Exercise 3 Design a function sorted-triple? which takes a Triple and produces a boolean indicating if the three numbers are in ascending order.

Exercise 4 Design a function sort-triple which takes a Triple and produces a new Triple in which the three numbers are in ascending order. The functions max and min may be helpful.

##### Recursive Structures

Exercise 5 Here is the data and structure definition for a ThreeTree.

;; A ThreeTree is one of: ;; - Number ;; - (make-three ThreeTree ThreeTree ThreeTree) (define-struct three (left mid right)) Write the template for ThreeTree and three data examples.

Exercise 6 Design the function count-tree which counts how many numbers are in a given ThreeTree.

Exercise 7 Design the function sum-tree which adds up all the numbers in a ThreeTree.

Exercise 8 Design the function product-tree which multiplies together all the numbers in a ThreeTree.

Exercise 9 Design the function decrease-tree which takes a ThreeTree and produces a new ThreeTree in which all of the numbers have been reduced by 7.

##### Lists and more lists

Exercise 10 Write the data defintion and template for a list of strings.

Exercise 11 Design the function total-string-length which computes the sum of the lengths of all the strings in a list. The string-length function will be useful.

Exercise 12 Design the function max-string-length which computes the length of the longest string in a list.

Exercise 13 Design the function longest-string which produces a string which has the longest length in the given list. Hint Think about what helper function you need to write to adapt the previous solution.