Function to return min_element index
static int min_element ( int [ ] arr ) { int idx = 0 ; int min = arr [ 0 ] ; for ( int i = 1 ; i < arr . length ; i ++ ) { if ( arr [ i ] < min ) { min = arr [ i ] ; idx = i ; } } return idx ; }