Skip to main content
1 of 6

Proving an algorithm wrong

So I have this algorithm that outputs the highest value of an array:

Input: A[1,..,n], n>=1 Output: Highest value of an array

Maximum (A)

  1. m = A[1]
  2. i = 1
  3. while i < n
  4. if A[i+1] > A[i]
  5.  m = A[i+1] 
  6. i = i+1
  7. return m

I have to prove this algorithm wrong and I'm confused how to do that, because to me the algorithm seems correct. Any advice on how to do this are very much appreciated.

Thanks!