Suppose a program contains a recursive method findFibonacci(int n), which computes the n-th Fibonacci number. Even if we know that a client method will never call findFibonacci( ) with the values 1 or 2 as arguments, why does the implementation of findFibonacci( ) still need to have base cases?

What will be an ideal response?


In the course of findFibonacci’s own recursion it will eventually reach values of n = 1 or 2 that it passes to itself. If these are not identified as base cases, then the recursion will logically continue forever, which is incorrect.

Computer Science & Information Technology

You might also like to view...

Which of the following is true?

a. An @RequestScoped bean can be access by all of an app's pages during a session. b. Sessions never expire. c. An @SessionScoped is created when a session begins and exists throughout the entire session. d. None of the above.

Computer Science & Information Technology

________ act as a window through which other people can enter records, filter records, and use your database

Fill in the blank(s) with correct word

Computer Science & Information Technology

Suppose that you want to modify the number of minutes that lapse before Word's AutoRecover feature creates a backup copy of a currently open document. What Word feature enables you to do that and after changing the number of minutes, will the change apply to only the current document, or to others that you create or modify?

What will be an ideal response?

Computer Science & Information Technology

What is it called when the contents of two bags are combined into a third bag?

A. iteration B. appending C. concatenation D. reduction

Computer Science & Information Technology