Algorithm of Linear Search In Array

It is an operation in which a given array can be searched for a particular value. The location of the searched element is informed.
Example: An Array series[N] we will search an element value 'X' and if it is found then its location is stored in POS.
If there is duplicate values in the series[N] then position of last duplicate value will be printed. That means the searching will go from very first element to the very last element of the array.

Algorithm:
1. C=1,pos=0
2. While (C<=N)
Perform step 3 and 4
3. If (series[C]='X' then Pos=c
4. c=c+1
5. Display Pos
6. End.

program linear search

11- Array- Linear Search-Algorithm & Program- DataStructure




    CLICK HERE TO Download This PDF NOTES




Facebook Likes

Youtube