go to previous page   go to home page   go to next page hear noise highlighting

Answer:


Two Views of Recursion

You need to be able to use both views. Sometimes when you are working on a problem you need to switch between these two views. You might write the code using the static viewpoint, then test and debug the code using the dynamic viewpoint.

Let us practice this. Here is the math-like definition of Triangle:

And here is another version of the Java method Triangle():

public int Triangle( int N )
{
    return N + Triangle( N-1 );
}

Say that you try to run this program..... but it never prints out a result.


QUESTION 19:

From a static viewpoint, what is wrong? (Remember the two things you need to get right.)

From a dynamic viewpoint, what is wrong?


go to previous page   go to home page   go to next page