Algorithms
Initialization: it is true prior to the first iteration of the loop
Maintenance: if it is true before an iteration of the loop, it remains
true before the next iteration
Termination: when the loop terminates, the invariant gives us a
useful pro

1. Write the Pseudocode and determine the time complexity of the given
searching and sorting algorithms.
[25 Marks]
Searching
Linear Search
LINEAR-SEARCH(A, key)
Begin
for i = 1 to A.length
if(A[i] = key)
return i
endif
endfor
return 0
End
Binary Search
B