Which one of the following requires a recursive solution (or the equivalent use of a stack or queue)?
1. The Fibonnaci function:
Fab(0) = 0;
Pib (1) = 1;
Fibn), n>l = Fib(n-1) + Fib(n-2)
2. Searching a connected directed graph
O 1 but not 2
0 2 but not 1
O Neither 1 nor 2
0 Both 1 and 2
Answers
Answer:
2. searching a connected directed graph
Answer:
Given below is the answer
Explanation:
A recursive algorithm calls itself with smaller input values and, after performing basic operations on the returned value for the smaller input, provides the result for the current input. A recursive method can typically solve a problem if smaller versions of the same problem can be solved by applying solutions to them, and the smaller versions shrink to easily solvable examples.
Recursive algorithm: what is it? Types and Technique
To build a recursive algorithm, you will break the given problem statement into two parts. The first one is the base case, and the second one is the recursive step.
Base Case: It is nothing more than the simplest instance of a problem, consisting of a condition that terminates the recursive function. This base case evaluates the result when a given condition is met.
Recursive Step: It computes the result by making recursive calls to the same function, but with the inputs decreased in size or complexity.
For example, consider this problem statement: Print sum of n natural numbers using recursion. This statement clarifies that we need to formulate a function that will calculate the summation of all natural numbers in the range 1 to n.
See more:
https://brainly.in/question/38600545
#SPJ3