I have some pseudo code for a recursive algorithm that finds the smallest number in an array.
Here is the algorithm.
Min(A[0..n - 1])
If n = 1 return A[0]
else
{
temp <-- Min(A[0..n - 2])
if temp <= A[n - 1]
return temp
else return A[n - 1]
}
One part I don't understand about this pseudo code is the line "temp <-- Min(A[0..n - 2])". Specifically why is it "n - 2" in the recursive call instead of "n - 1"?
My other question is how I would implement that line in code. I am using Java.
Thanks in advance for any help.