My programming is not working .. does anyone know how to correct it ?

this is my problem :

Write a function that computes the minimum in an array recursively. The key to this problem is the
following: If we have an array A[0:::N 1], and we know the minimum of two chunks of the array, namely
m1 = min(A[1:::j]) and m2 = min(A[j + 1:::N 1]), then min(A[0:::N 1]) is nothing but the minimum of
m1 and m2. The declaration of the function can for example be as follows:

and this is the code i have written


#include <iostream>
using namespace std ;


// suppose we have an array of size 6
// let this array be :
// 3 7 1 9 0 2
// to find the minimum in this list
// we compare 3 to the minimum of 7 1 9 0 2
// and then to find the minimum in 7 1 9 0 2
// we do the same thing , so we compare 7 to the minimum in 1 9 0 2
// ...

return 0 ;

}

int find_minimum ( const int list[] , int left_index ,int right_index )
{ if ( right_index == left_index ){

return list [right_index] ;
// we can also retuern list [left_index] ;

}
else {
int min =0 ;
min = find_minimum (list ,left_index +1 , right_index ) ;
if (min <= list [right_index])
{return min ;
}
else return list [right_index];
}
}
Topic archived. No new replies allowed.