From the above code,
i←0
while i < n−2do
if A[i]A[i+1]> A[i+ 2] then
returning i
i←i+ 1
return−1
For the best case- for all the value of n which is less than or equal to 2, it will show the best case input.
For the worst case input, if the value of n which will be greater than 2, and value of n will be greater then the termination of loop will go longer, so in that case it will show worst case input.
Comments
Leave a comment