Understanding Recursion
4 posters
Advanced Modularization Techniques :: Advanced Modularization Techniques :: Advanced Modularization Techniques
Page 1 of 1
Understanding Recursion
Recursion
Every time you call a method, the address to which the program should return at the
completion of the method is stored in a memory location called the stack . When a method
ends, the address is retrieved from the stack and the program returns to the location where
the method call was made, then proceeds to the next instruction.
Occurs when a method is defined in terms of itself. A method that calls itself is a
recursive method . Some programming languages do not allow a method to call itself, but
those that do can be used to create recursive methods that produce interesting effects.
recursive method . Some programming languages do not allow a method to call itself, but
those that do can be used to create recursive methods that produce interesting effects.
Every time you call a method, the address to which the program should return at the
completion of the method is stored in a memory location called the stack . When a method
ends, the address is retrieved from the stack and the program returns to the location where
the method call was made, then proceeds to the next instruction.
Re: Understanding Recursion
What is the used of recursion?
Last edited by johnarnold on Thu Aug 23, 2018 12:18 pm; edited 1 time in total
johnarnold- GURU
- Posts : 10
Join date : 2018-08-23
Re: Understanding Recursion
does java supports recursion?
johnarnold- GURU
- Posts : 10
Join date : 2018-08-23
Re: Understanding Recursion
Recursion in C Language
Advantages of Recursion:
1. Reduce unnecessary calling of function.
2. Through Recursion one can Solve problems in easy way while its iterative solution is very big and complex.For example to reduce the code size for Tower of Honai application, a recursive function is bet suited.
3. Extremely useful when applying the same solution.
Disadvantages of Recursion:
1. Recursive solution is always logical and it is very difficult to trace.(debug and understand).
2. In recursive we must have an if statement somewhere to force the function to return without the recursive call being executed, otherwise the function will never return.
3. Recursion takes a lot of stack space, usually not considerable when the program is small and running on a PC.
4. Recursion uses more processor time.
skl
Advantages of Recursion:
1. Reduce unnecessary calling of function.
2. Through Recursion one can Solve problems in easy way while its iterative solution is very big and complex.For example to reduce the code size for Tower of Honai application, a recursive function is bet suited.
3. Extremely useful when applying the same solution.
Disadvantages of Recursion:
1. Recursive solution is always logical and it is very difficult to trace.(debug and understand).
2. In recursive we must have an if statement somewhere to force the function to return without the recursive call being executed, otherwise the function will never return.
3. Recursion takes a lot of stack space, usually not considerable when the program is small and running on a PC.
4. Recursion uses more processor time.
skl
johnarnold- GURU
- Posts : 10
Join date : 2018-08-23
Re: Understanding Recursion
Is recursion faster than loops?
johnarnold- GURU
- Posts : 10
Join date : 2018-08-23
Re: Understanding Recursion
can you give a sample program that uses recursion?
thegreatunknown- GURU
- Posts : 10
Join date : 2018-09-03
Re: Understanding Recursion
Not sure, but it should.johnarnold wrote:does java supports recursion?
thegreatunknown- GURU
- Posts : 10
Join date : 2018-09-03
Re: Understanding Recursion
I think loops are faster because it contains less process than a function.johnarnold wrote:Is recursion faster than loops?
thegreatunknown- GURU
- Posts : 10
Join date : 2018-09-03
Re: Understanding Recursion
what are those programming language does not use recursion method ?
DespicableMe- GURU
- Posts : 10
Join date : 2018-10-01
Re: Understanding Recursion
what are the uses of Recursion method?
DespicableMe- GURU
- Posts : 10
Join date : 2018-10-01
Re: Understanding Recursion
Recursion method can be ended or it just like a Infinite loop ?
DespicableMe- GURU
- Posts : 10
Join date : 2018-10-01
Advanced Modularization Techniques :: Advanced Modularization Techniques :: Advanced Modularization Techniques
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|