|
From: <and...@su...> - 2003-06-09 01:11:27
|
Dear Users,
Please consider the followin code:
#include <iostream>
using std::cout;
using std::endl;
#include <cstdlib>
void someFunction(int [], int);
int main()
{
const int arraySize = 10;
int a[arraySize] = {32, 27, 64, 18, 95, 14, 90, 70, 60, 37};
cout << "Array values are:" << endl;
someFunction(a, arraySize); // the array is printed in reversal order
cout << endl;
system("PAUSE");
return 0;
}
1-void someFunction(int b[], int size)
2-{
3- if(size > 0)
4- {
5- someFunction(&b[1], size-1);
6- cout << b[0] << " ";
7- }
8-}
A) I allways worked with recursive functions that had an explict
Basic Case, i.e., an "if" statement, and a return command;
B) Here in this recursive function there isn´t a if/return command
as you can see. I think when the calls arrive in the
"someFunction(&b[9], size-9);", the cout in line 6 is executed;
My Questions:
1) Is there any implicit basic case for recursive functions without an
explicit if/return command?
2) How is the dynamic of this function? All the calls to someFunction are
made and only after this the command of line 6 is made? In the last call
for the 10th element?
Regards
Andre
|