MCS-177, Intro. to Computer Science I, Fall 2002
Review Problems for Chapter 7
- Basic list manipulations
- Write a procedure that will find the product of a list of
numbers.
- Write a procedure that will produce a list with n copies of a
given element.
- Write a procedure that will double every element in a list.If you
double the list (1 2 3), you get the list (1 1 2 2 3 3).
- Lists and iteration
Write a procedure that will find the largest element in a list.
- Lists and time complexity
- Write a procedure that will take two lists and append one to the
other. The new list should be a list consisting of the elements of
the first list followed by the elements of the second list.
- What is the time complexity of your procedure, in terms of the
sizes of the lists?
- Lists and higher order programming
- Write a procedure that takes a list of functions and a number
and produces the list of the values of the functions when applied to
the number.
- Write a procedure called compose that will take a list of procedures and
produces the procedure that is the composition of the procedures in
the list. For example,
((compose (list square add-one)) 3) ==> 16
- Lists and tree recursion
This is a challenging problem. An s-list is either a number,
a symbol, or a list of s-lists. Thus, ((2) 3 ((4) a) () ) is an s-list.
Write a procedure called flatten that will take an s-list and
turn it into a list of just symbols and numbers. If we flatten the
list above, we get the list (2 3 4 a).
MCS 177 homepage