Implement a recursive function to reverse a sorted array.

Jul 31, 2013 at 2:16pm
Implement a recursive function to reverse a sorted array. Ie, given the array [ 1, 2, 3, 4, 5] your
procedure should return [5, 4, 3, 2, 1].


1
2
3
int reverse(int mydata[], int start, int end){
return reverse(...)
Jul 31, 2013 at 3:58pm

1
2
3
4
5
6
7
void thefunction (int mydata[], int end) 
{
if (end > 0)
{ 
cout << mydata[end]; 
thefunction (mydata [], end -1); 
}



Is this what your looking for?
Last edited on Jul 31, 2013 at 5:55pm
Jul 31, 2013 at 6:11pm
@kingkong200


Your function does not reverse arrays. And moreover it is simply incorrect and contains a bug.
Last edited on Jul 31, 2013 at 7:46pm
Topic archived. No new replies allowed.