### Present Remotely

Send the link below via email or IM

• Invited audience members will follow you as you navigate and present
• People invited to a presentation do not need a Prezi account
• This link expires 10 minutes after you close the presentation

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

# Recursion

No description
by

## عبدالرحمن ايهاب

on 9 April 2012

Report abuse

#### Transcript of Recursion

void Dream()
{
bool kick = CheckForKick();
if(kick)
return;

Dream();
}
Examples
Recursion
Problem => subproblems
HOW ??!!
int factorial(int n)
{
if(n == 0)
return 1;
else
return n*factorial(n-1);
}
string s = "Recursion";
void print(int i)
{
if(i == s.size())
{
cout << endl;
return;
}
cout << s[i];
print(i + 1);
}
Base Case
Recursive Call
Not all problems that are solvable with recursion are solvable with loop.
Dream Stack
Reverse it
void print(int i, string s)
{
if(i == s.size())
return;

print(i + 1, s);
cout << s[i];
}
Thank you
prepared by Abdelrahman Ihab
int fib(int n)
{
if(n == 0)
return 0;

if(n == 1)
return 1;

return fib(n-1) + fib(n-2);
}
Full transcript