Compilers Principles, Techniques, & Tools (purple dragon book) second edition exercise answers

Exercises for Section 7.5

7.5.1

What happens to the reference counts of the objects in Fig. 7.19 if:

  1. The pointer from A to B is deleted.
  2. The pointer from X to A is deleted.
  3. The node C is deleted.

A network of objects

Figure 7.19: A network of objects

Answer

  1. The pointer from A to B is deleted.

    7 5 1-1

  1. The pointer from X to A is deleted.

    7 5 1-2

  1. The node C is deleted.

    7 5 1-3

7.5.2

What happens to reference counts when the pointer from A to D in Fig. 7.20 is deleted?

Another network of objects

Figure 7.20: Another network of objects

Answer

7 5 2