Lab 6 Practice Exercise Solutions

  1. In the figure, variables are rectangles and objects are circles.

  2. a = (1)
    b = (2 1)
    c = (2 1)
    d = (4 5 6 2 1)
    

  3. The italicized number is the memory location of each object.

  4. Locations 108 and 109 are not used.

  5. Notice that part of the list is shared.


    Now 108, 109, 114, and 115 are not used

  6. Memory LocationMemory Contents
    200 1
    201 0
    202 2
    203 200
    204 3
    205 202
    206 6
    207 202
    208 5
    209 206
    210 4
    211 208

    Local variables and what they reference:
    a = 200
    b = 202
    c = 202
    d = 210

    Locations 204 and 205 contain garbage.