Linear Search

Linear Search :

ALGORITHM:
      1. [INITIALIZE] FLAG=0
      2. Input Array of size n, say, A[n]
      3. Input the element to search for, say, num
      4. for i=0 to (n-1)
        if(A[i]==num)
        set LOC=(i+1)
        set FLAG=1  and exit the loop
      5. Print the LOC if FLAG=1
        else  print  “ELEMENT NOT FOUND”;

C SOURCE CODE :

Leave a Reply

Your email address will not be published. Required fields are marked *