A community for students. Sign up today!
Here's the question you clicked on:
 0 viewing

This Question is Closed

shahzadjalbani
 2 years ago
Best ResponseYou've already chosen the best response.1@ash2326 @AwkwardsWhatIAmFor @ash__arya @ByteMe @bballer100 @bluesgut @Captain_Page_Turner @Chris2332 @comphw @DHASHNI @devendra_iiti

DHASHNI
 2 years ago
Best ResponseYou've already chosen the best response.6recursion 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.

shahzadjalbani
 2 years ago
Best ResponseYou've already chosen the best response.1@surdawi @SWAG @sue101

Chris2332
 2 years ago
Best ResponseYou've already chosen the best response.0Hi, how did you find the replies by DHASHNI?

Chris2332
 2 years ago
Best ResponseYou've already chosen the best response.0because he tagged another 3 people after the reply... which seems a bit weird!

DHASHNI
 2 years ago
Best ResponseYou've already chosen the best response.6well if he's not satisfied with my idea ..... he should shift is'nt it!!!!

shahzadjalbani
 2 years ago
Best ResponseYou've already chosen the best response.1Explain further I understood little bit I need more explanation.... @DHASHNI @ash2326 @AwkwardsWhatIAmFor @ash__arya @hartnn @kropot72 @LonelyandForgotten

DHASHNI
 2 years ago
Best ResponseYou've already chosen the best response.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 ifstatement 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)
Ask your own question
Ask a QuestionFind more explanations on OpenStudy
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
 Engagement 19 Mad Hatter
 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.