Recursion help
1 2 3 4 5 6 7 8 9
|
void review(int n)
{
if (n>0)
{
review(n/2);
cout <<n<<" ";
}
}
|
If i called review(14) would the output be 1 3 7 14?
I ran this code in visual c++ and that is what it returned but I do not understand how it starts with 1 and not 14?
1 2 3 4 5 6 7 8 9
|
1.review(14)
2. --> review(7)
3. --> review(3)
4. --> review(1)
5. --> review(0) max recursive depth, start returning in FILO order
6. --> 1
7. --> 3
8. --> 7
9.--> 14
|
Topic archived. No new replies allowed.