MCS-388 Homework 4 (Spring 2005)
Due: April 12, 2005
-
Do exercise 5.3 on page 336. However, modify the problem to use -
(subtraction) in place of + (addition).
-
Do exercise 8.12 on page 509.
To generate concrete code, you need to know the answers to several questions:
-
How big are the arrays? Are they 10x20, like in the book's example,
or some other size?
-
Do the indices start at 1, 0, or some other lower
bound?
-
How large are the individual array elements? 4 bytes? 8?
Something else?
For all these questions, feel free to either pick some concrete
numbers (like the 10x20), state them, and then work using them, or
give symbolic names to the quantities (like saying the array is NxM,
with K bytes per element) and then give answers that have expressions
containing these symbolic names, even when they really would be
crunched down to a single constant. You also need to make a choice of
whether the arrays are stored in row-major or column-major order.
-
Write three programs in Scheme. The first should be such that a
compiler could use static allocation for all of the program's
variables. The second should be such that static allocation would not
work for all the variables, but stack allocation would. The third
should be such that even stack allocation wouldn't work; instead, the
compiler will need to use heap allocation for at least some of the
variables.
Course web site: http://www.gustavus.edu/+max/courses/S2005/MCS-388/
Instructor: Max Hailperin <max@gustavus.edu>