Home /
Expert Answers /
Computer Science /
1-6-points-prove-that-the-following-algorithm-is-correct-by-using-the-34-proof-by-loop-invariants-pa332
(Solved):
1. (6 points) Prove that the following algorithm is correct by using the "Proof by Loop Invariants ...
1. (6 points) Prove that the following algorithm is correct by using the "Proof by Loop Invariants" method. Hint: Loop Invariant S;=x is not equal to any of the first i elements of the array Algorithm arrayFind(x, A): Input: An element and an n-element array, A. Output: The index i such that x = A[i] or -1 if no element of A is equal to x. i-0 while i < n do if x = A[i] then return i else i+i+1 return -1