i am currently working on the program that uses recursion...summarizing it ---> have to enter 10 integers into an array and using recursion and and binary search (divide into 2 smaller problems)...
the only thing that gets me stuck is how can I dynamicaly check the size of array as we go deeper and deeper into each recursive call...????? the reason for this is that i need a base (stopper) case that will return a value when an array will have only 1 member...???
i will include the code for this function...
i have commented the problems....
int MaxArray(int Array[], int First, int Last)
{
int Largest;
int Mid = (Array[Last]) / 2; // finding midpoint
if (Last == 1) // won't work..... NOT (Last)
Largest = Array[Last]; // need to have a different base case
// not totally different (just the tiny bit different)
else
{
MaxArray(Array, First, Mid); // One half including midpoint
MaxArray(Array, (Mid + 1), Last); //Second half
// recursive call...
}
// i have to send the results to another function to compare
// integers in term of size......and return the biggest one.
}
i have done the same problem in various easier ways, this time i need to do it this way...
i would appreciate any suggestions and any help...
thanx