Recursive Function

  • In one function definition, if you call the same function, those type of functions are called as a Recursive function.
i.e. main()
i.e. void abc()
Answer : Hello
         (after certain time it will give segmantation fault because the memory will be full)

Things to remember while designing recursive function :

  1. Function prototype must be concentrated.
  2. Maximum avoid loops in a recursive function.
  3. Maximum try to write a code in if…else part.
  4. The Proper Return statement should be there in the if..else part if recursive function is returning something.

Advantage :

  • When we design big algorithm i.e. Binary search string, Sorting we can reduce the size of code by the help of recursive.

Disadvantage :

  • Slower in execution, because every time we call function stack frame will create.
  • It needs more space/memory or stack size.

We will see an example of this in the Programming section.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by

Up ↑

%d bloggers like this: