Answer the following statements true (T) or false (F)

1. A recursive function is a function whose definition contains a call to the function being defined
2. A design technique is to break a problem into smaller tasks, with the prospect that a smaller problem will be easier to solve. If the smaller task is the identical to the original task excepting only that the size is smaller, the problem may be solved using a recursive algorithm, and implemented with a recursive function.
3. It is proper for a recursion to run on without ending.
4. A proper recursive solution requires at least two cases: a recursive function that calls the recursive function with a smaller problem, and a base, or stopping case.
5. In recursion, it is unnecessary to decide whether a stopping case has been reached.

1. True
Any function that calls itself is referred to as recursive.
2. True
3. True
Nevertheless, a program that was written by a student at this level that does not terminate, is likely to be wrong, whether the failure to terminate is due to an infinite loop or a recursion that does not stop. It is not true that every program that does not terminate is wrong. Some programs have an intentional infinite loop. Examples include an ATM program and reservation systems that typically have an outer loop that repeats the service menu forever. Windowing systems (a.k.a. graphical user interfaces, or GUIs) also have an event loop that does not terminate. This loop waits for an event such as a mouse click or keystroke.
4. True
This is the general outline of a successful recursion.
5. False
In recursion, termination requires that a stopping case be reached. It is necessary to decide whether this case has been reached.

Computer Science & Information Technology

You might also like to view...

Which of the following does not contain a syntax error?

a. System.out.println('Hello world!'): b. System.out.println("Hello world!"); c. System.out.println("Hello world!"); d. System.out.println(Hello world!);

Computer Science & Information Technology

The price of a laptop computer increases when you add processing power, ____________________, and storage space. 

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology