Linear Search


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
      

Use this animation to understand it better...

Go ahead, enter a key item to search from given list, and later you can try enter your own list and search your desired item





Linear search is very simple and basic kind of search algorithm. It's time complexity is O(N). So, for very minor search tasks this may be used, but it cannot be used for large real world search problems. For a better search algorithm we can see Binary Search algoritm whose time complexity is O(log N) which is comparatively much better than linear search but adds the overhead of sorting the data.