Recursion Problems. Pls Help!

Hi there,

I'm currently having difficulties in implementing fully recursive methods (those which do not use loops at all) and was wondering if anyone can give me a hand since i can't seem to grasp this topic.

the first method to implement is

*boolean allEqual(int[] a, int start, int end) that checks if all elements in the array a from start to end are equal.*

my code is as follows as I cannot seem to understand how to implement it.

**public static boolean allEqual(int[] a, int start, int end){**

if (start==end) return true;

boolean success = allEqual(a,start,end);

if (success) return true;

success = allEqual(a,start+1,end);

return success;

I'm not entirely sure if my base case is correct, so if someone can point that out it would be great. Returning a boolean from a recursive method confuses me. :confused:

the other method is

*boolean linearSearch(int[] a, int x, int start, int end) that checks if the array a contains the element x anywhere between the indices start and end.*

and what i have done is

**public static boolean linearSearch(int[] a, int x, int start, int end){**

if (start==end) return a[start]==x;

if (a[start]>a[end])

return linearSearch (a, x, start+1, end);

else return false;

}

again sorry, if my implementation looks like non sense. I have only recently started to understand how to implement basic recursive methods -- ones that don't deal with arrays such as factorials and harmonicSums.