Answer the question
In order to leave comments, you need to log in
Invariant in linear search?
There is a linear search algorithm
A = {1, 2, 7, 5, 8}
v = 7
def search(A, v)
i = 0
while i < A.length do
if A[i] == v then
return i
end
i++
od
return nil
end
Answer the question
In order to leave comments, you need to log in
1. A[i] ∈ A
2. i ∈ {0, ...A.length - 1} or i ∈ {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question