Skip to content

pr-coder-kaya/java_recursion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recursion

-Recursion is the technique of making a function call itself -Basically, one method is invoking itself -Infinite recursion – method never stops calling itself

Disadvantages of Recursion#

-A recursive program has greater space requirements than an iterative program as each function call will remain in the stack until the base case is reached. -It also has greater time requirements because each time the function is called, the stack grows and the final answer is returned when the stack is popped completely.

Advantages of Recursion#

-For a recursive function, you only need to define the base case and recursive case, so the code is simpler and shorter than an iterative code. -Some problems are inherently recursive, and we need to implement recursion.

RECURSIVELY DEFINED FUNCTIONS

-A function is said to be recursively defined if the function refers to itself such that

  1. There are certain arguments, called base values, for which the function does not refer to itself.
  2. Each time the function does refer to itself, the argument of the function must be closer to a base value.

USE OF RECURSION

For every recursive algorithm, there is an equivalent iterative algorithm. -However, iterative algorithms are usually more efficient in their use of space and time.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages