COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which of the following best describes an essential characteristic that can be used to distinguish a recursive algorithm from a nonrecursive algorithm?
A
Being implemented with a procedure or method that has one parameter
B
Creating and initializing an accumulator to store the result while the algorithm is running
C
Making progress toward a solution by running the algorithm on a smaller version of the original problem
D
Returning a fixed, literal value in the simplest case or cases
Explanation: 

Detailed explanation-1: -Like the robots of Asimov, all recursive algorithms must obey three important laws: A recursive algorithm must call itself, recursively. A recursive algorithm must have a base case. A recursive algorithm must change its state and move toward the base case.

Detailed explanation-2: -Data structure used in a non recursive implementation of a recursive algorithm-Stack.

Detailed explanation-3: -Stack data structure is used for implementing the recursion.

Detailed explanation-4: -Recursion is a process in which the function calls itself indirectly or directly in order to solve the problem. The function that performs the process of recursion is called a recursive function. There are certain problems that can be solved pretty easily with the help of a recursive algorithm.

There is 1 question to complete.