Algorithm |
||
Linear Search
Linear Search is an algorithm to find a specified elements in a list or array by search through all the elements from the beginning one by one.
Overall sequence of Linear Search algorithm is as follows (This is a kind of pseudo code, try to implement this using any language you are familiar with): i) An array (or List) is given. Let's call this array as A[] ii) An element to be found is given. Let's call this elements as 'eTofind'. iii) Set a position of index i = 0 iv) set the status variable IsFound = False iv) Do the followings Label : Loop if A[i] == eToFind then IsFound = True and goto step v) else i = i + 1 go to Loop v) Print(or return) IsFound
|
||