Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Linear Search in DSA(Data Structure and Algorithms)

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 374
    Comment on it

    Linear search is simple search algorithm in which a sequential searching is done over all the items in a list. Every items are checked and if any match is found then that item is returned otherwise search will be continuued till the end of the data collection.

    In DSA two type of code are there one is algorithm and the other one is pseudo code.

    Here's the pseudo code and algorithm of linear search in DSA

    1.Pseudocode:-

    procedure linear_search (list, value)
    
       for each item in the list
    
          if match item == value
    
             return the item's location
    
          end if
    
       end for
    
    end procedure
    

    2.Algorithm:-

    Linear Search ( Array A, Value x)
    
    Step 1: Set i to 1
    Step 2: if i > n then go to step 7
    Step 3: if A[i] = x then go to step 6
    Step 4: Set i to i + 1
    Step 5: Go to Step 2
    Step 6: Print Element x Found at index i and go to step 8
    Step 7: Print element not found
    Step 8: Exit
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: