CSE 461: Programming Languages Concepts
Prof. G. Tan
Spring 2022
Homework 7
Due on Apr 27th at 6pm;
Submission: Only a 3-day late submission will be allowed, as we
want to release the solution early for you to prepare for the final exam.
Please submit your homework via Canvas. It’s okay if you submit a scanned
version of your on-paper answers, but please make sure your scanned version
is legible.
1. (4 points) For each of the following Racket lists, draw its memory
epresentation using atom and cons cells:
(a) ’(everyday (is a) new beginning)
(b) ’((everyday is) (a) new (beginning))
2. (4 points) For each of the following Racket expressions, draw the mem-
ory representation of its result after its evaluation:
(a) (cons (cons ’b ’c) (cons ’b ’c))
(b) ((lambda (x) (cons x x)) (cons ’b ’c))
3. We have a Racket program below:
(define lst ’(Racket (is fun)))
(define lst (car (cdr lst)))
(define lst (cons ’Racket lst))
(a) (2 points) Draw the memory layout in terms of cells for each
execution step of the above program. Assume Ga
age Collection
does not run in intermediate steps.
(b) (1 point) What is the value of lst at the end?
(c) (1 point) Suppose the system decides to perform a Mark-and-
Sweep Ga
age Collection at the end, which memory cells would
e recycled?
1