Login or Create an Account to view the mark scheme, comment, and add to a test
Consider the following recursive algorithm, where arr refers to an array type input.
[3]function mystery(arr, i)
if i = 0
output "not found"
return false
if arr[i - 1] = 7 then
output i
return true
else
mystery(arr, i - 1)
end if
end function
State the output of mystery( [3,1,5,7,9,2] , 6 ) and describe what the mystery function generally achieves when the initial inputs for arr and i refer to an array and its corresponding length respectively.
Short Answer3 MarksPremium
12 Uses63 Views0 Likes