Consider the searching problem: Input: A sequence of n numbers A = a 1 , a 2
Question:
Consider the searching problem:
Input: A sequence of n numbers A = 〈a1, a2,......,an〉 and a value ν.
Output: An index i such that ν = A[i] or the special value NIL if ν does not appear in A.
Write pseudocode for linear search, which scans through the sequence, looking for ν. Using a loop invariant, prove that your algorithm is correct. Make sure that your loop invariant fulfills the three necessary properties.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Question Posted: