Linear Search

Linear search is a straightforward search technique. A sequential search is performed across all objects one by one in this sort of search. Every item is verified, and if a match is discovered, that item is returned; otherwise, the search continues until the data collection is completed.

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

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
0

2 thoughts on “Linear Search”

  1. I’ve been looking for photos and articles on this topic over the past few days due to a school assignment, casino online and I’m really happy to find a post with the material I was looking for! I bookmark and will come often! Thanks 😀

    0
  2. Pingback: 1history

Leave a Comment

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

eight − four =