Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

shahzadjalbani Group Title

Please define Recursion Function in C++.

  • 2 years ago
  • 2 years ago

  • This Question is Closed
  1. shahzadjalbani Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    @ash2326 @AwkwardsWhatIAmFor @ash__arya @ByteMe @bballer100 @bluesgut @Captain_Page_Turner @Chris2332 @comphw @DHASHNI @devendra_iiti

    • 2 years ago
  2. DHASHNI Group Title
    Best Response
    You've already chosen the best response.
    Medals 6

    recursion is when a function calls itself.That is, in the course of the function definition there is a call to that very same function. At first this may seem like a never ending loop, or like a dog chasing its tail. It can never catch it. So too it seems our function will never finish. This might be true is some cases, but in practice we can check to see if a certain condition is true and in that case exit (return from) our function. The case in which we end our recursion is called a base case . Additionally, just as in a loop, we must change some value and incrementally advance closer to our base case.

    • 2 years ago
  3. DHASHNI Group Title
    Best Response
    You've already chosen the best response.
    Medals 6

    http://www.danzig.us/cpp/recursion.html

    • 2 years ago
  4. shahzadjalbani Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    @surdawi @SWAG @sue101

    • 2 years ago
  5. Chris2332 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi, how did you find the replies by DHASHNI?

    • 2 years ago
  6. DHASHNI Group Title
    Best Response
    You've already chosen the best response.
    Medals 6

    y so ...

    • 2 years ago
  7. Chris2332 Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    because he tagged another 3 people after the reply... which seems a bit weird!

    • 2 years ago
  8. DHASHNI Group Title
    Best Response
    You've already chosen the best response.
    Medals 6

    thats ok!!!!

    • 2 years ago
  9. DHASHNI Group Title
    Best Response
    You've already chosen the best response.
    Medals 6

    well if he's not satisfied with my idea ..... he should shift is'nt it!!!!

    • 2 years ago
  10. shahzadjalbani Group Title
    Best Response
    You've already chosen the best response.
    Medals 1

    Explain further I understood little bit I need more explanation.... @DHASHNI @ash2326 @AwkwardsWhatIAmFor @ash__arya @hartnn @kropot72 @LonelyandForgotten

    • 2 years ago
  11. DHASHNI Group Title
    Best Response
    You've already chosen the best response.
    Medals 6

    #include <stdio.h> void recurse ( int count ) /* Each call gets its own copy of count */ { printf( "%d\n", count ); /* It is not necessary to increment count since each function's variables are separate (so each count will be initialized one greater) */ recurse ( count + 1 ); } int main() { recurse ( 1 ); /* First function call, so it starts at one */ return 0; } ====>>> This simple program will show the number of times the recurse function has been called by initializing each individual function call's count variable one greater than it was previous by passing in count + 1. Keep in mind that it is not a function call restarting itself; it is hundreds of function calls that are each unfinished. The best way to think of recursion is that each function call is a "process" being carried out by the computer. If we think of a program as being carried out by a group of people who can pass around information about the state of a task and instructions on performing the task, each recursive function call is a bit like each person asking the next person to follow the same set of instructions on some part of the task while the first person waits for the result. At some point, we're going to run out of people to carry out the instructions, just as our previous recursive functions ran out of space on the stack. There needs to be a way to avoid this! To halt a series of recursive calls, a recursive function will have a condition that controls when the function will finally stop calling itself. The condition where the function will not call itself is termed the base case of the function. Basically, it will usually be an if-statement that checks some variable for a condition (such as a number being less than zero, or greater than some other number) and if that condition is true, it will not allow the function to call itself again. (Or, it could check if a certain condition is true and only then allow the function to call itself)

    • 2 years ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.