8
Reversing 8 (define (list-reverse p) (if (null? p) null (list-append (list-reverse (cdr p)) (list (car p))))) (define (list-reverse p) (if (null? p) null (list-append (list-reverse (cdr p)) (list (car p))))) Running time is in  (N 2 ) where N is number of elements in p. Number of new cons cells: for the list-appends: N-1 + N-2 + … + 1 = N 2 / 2 + for the (list (car p)): N memory use is in  (N 2 ) Define a mlist-reverse! that reverses the elements of a list. The number of cons cells it creates should not scale with the length of the list.

9
mlist-reverse! 9 Define a mlist-reverse! that reverses the elements of a mutable list. The output should be a mutable list with the elements in the reverse order. The number of cons cells it creates should not scale with the length of the list. (The input list can be mutated arbitrarily!) Hint: define a helper procedure that takes two inputs.