Chapter 9

Problem Set:

2. The main advantage of this method is the fast accesses to formal parameters in subprograms.  The disadvantages are that recursion is rarely useful when values cannot be passed, and also that a number of problems, such as aliasing, occur with the method.

4. This can be done in both Java and C#, using a static (or class) data member for the page number.

5. Assume the calls are not accumulative; that is, they are always called with the initialized values of the variables, so their effects are not accumulative.

    a. 2, 1, 3, 5, 7, 9      b. 1, 2, 3, 5, 7, 9          c. 1, 2, 3, 5, 7, 9         

        2, 1, 3, 5, 7, 9          2, 3, 1, 5, 7, 9              2, 3, 1, 5, 7, 9

        2, 1, 3, 5, 7, 9          5, 1, 3, 2, 7, 9              5, 1, 3, 2, 7, 9 (unless the addresses of the

                                                                                                    actual parameters are

                                                                                                    recomputed on return, in

                                                                                                    which case there will be an

                                                                                                    index range error.)

                                                                                                           

6. It is rather weak, but one could argue that having both adds complexity to the language without sufficient increase in writability.