This is the pseudo-code from the problem:
Procedure Foo(A,f,L)
, precondition:
- A[f..L] is an array of integers
- f,L, are two naturals >=1 with f<=L.
Code
procedure Foo(A,f,L
if (f=L) then
return A[f]
else
m <-- [(f+L)/2]
return min(Foo(A,f,m), Foo(A, m+1,L))
end if
The Question:
Using induction, argue that Foo invokes min at most n-1 times.
I am a little lost on how to continue my proof for part (iii). I have the claim written out as well as the base case. Which i believe it to be n>=2. But how do I do it for k + 1 terms? Since this is a proof by induction.
Thanks