Which of the following is required in a recursive function?
a. Exactly one recursive call and exactly one stopping case.
b. Calls to functions other than itself.
c. One or more stopping cases after a sequence of calls to one or more recursive cases.
d. A static local variable.
e. One or more stopping cases that are guaranteed to be reached.
Parts c) and e) are required in a recursive function. Part c) is the text’s model, where there will be one or more recursive calls and one or more stopping cases. Part e) provides the required guaranteed termination of recursion.
Explanation: All of these are possible in a recursive function. However, part a) is too restrictive. Part b) is not required for a recursive function. However, the nonrecursive case may call another function. A collection of mutually recursive functions is certainly a possibility. A first function may have a (potentially recursive) call to another functions that in turn may (recursively) call the first function. Part d): Any function, including a recursive function, may have a static local variable.
You might also like to view...
The ISDN PRI contains
a. 2 B-channels b. 23 B-channels c. 2 D-channels d. 23 D-channels
What does the investigator in a criminal or public-sector case submit, at the request of the prosecuting attorney, if he or she has enough information to support a search warrant?
a. A blotter b. An exhibit report c. A litigation report d. An affidavit
Which of the following C statements reads a character, an integer, and a real in that order?
A. %c, %d, %f B. %c, %d, %r C. %c%d%r D. %c %d %f E. %cdr
Here is a simpler version of the add(Object, int) method from Section 3.4.9. Under what circumstances will it fail? How do you fix this problem?
```
1 public void add( E e, int p ) {
2 if (( p < 0 ) || ( p > length ) )
3 throw new IndexOutOfBoundsException();
4 SLNode