Understanding Recursion

Go down

Understanding Recursion

Post by Admin on Fri Aug 17, 2018 8:51 am

Recursion

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.




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.
avatar
Admin
Admin

Posts : 3
Join date : 2018-08-13
Age : 20

View user profile http://odessaeiman.forumotion.com

Back to top Go down

Re: Understanding Recursion

Post by johnarnold on Thu Aug 23, 2018 12:16 pm

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

View user profile

Back to top Go down

Re: Understanding Recursion

Post by johnarnold on Thu Aug 23, 2018 12:18 pm

does java supports recursion?

johnarnold
GURU

Posts : 10
Join date : 2018-08-23

View user profile

Back to top Go down

Re: Understanding Recursion

Post by johnarnold on Thu Aug 23, 2018 12:26 pm

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

johnarnold
GURU

Posts : 10
Join date : 2018-08-23

View user profile

Back to top Go down

Re: Understanding Recursion

Post by johnarnold on Thu Aug 23, 2018 12:27 pm

Is recursion faster than loops?

johnarnold
GURU

Posts : 10
Join date : 2018-08-23

View user profile

Back to top Go down

Re: Understanding Recursion

Post by thegreatunknown on Mon Sep 03, 2018 1:36 pm

can you give a sample program that uses recursion?

thegreatunknown
GURU

Posts : 10
Join date : 2018-09-03

View user profile

Back to top Go down

Re: Understanding Recursion

Post by thegreatunknown on Mon Sep 03, 2018 1:41 pm

johnarnold wrote:does java supports recursion?
Not sure, but it should.

thegreatunknown
GURU

Posts : 10
Join date : 2018-09-03

View user profile

Back to top Go down

Re: Understanding Recursion

Post by thegreatunknown on Mon Sep 03, 2018 1:43 pm

johnarnold wrote:Is recursion faster than loops?
I think loops are faster because it contains less process than a function.

thegreatunknown
GURU

Posts : 10
Join date : 2018-09-03

View user profile

Back to top Go down

Re: Understanding Recursion

Post by DespicableMe on Wed Oct 03, 2018 9:11 am

what are those programming language does not use recursion method ?

DespicableMe
GURU

Posts : 10
Join date : 2018-10-01

View user profile

Back to top Go down

Re: Understanding Recursion

Post by DespicableMe on Wed Oct 03, 2018 9:17 am

what are the uses of Recursion method?

DespicableMe
GURU

Posts : 10
Join date : 2018-10-01

View user profile

Back to top Go down

Re: Understanding Recursion

Post by DespicableMe on Wed Oct 03, 2018 9:57 am

Recursion method can be ended or it just like a Infinite loop ?

DespicableMe
GURU

Posts : 10
Join date : 2018-10-01

View user profile

Back to top Go down

Re: Understanding Recursion

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum