def linear_search(given_arr, search_for):
         search_at = 0
         search_res = False
      # Match the value with each data element	
         while search_at < len(given_arr) and search_res is False:
            if given_arr[search_at] == search_for:
               search_res = True
            else:
               search_at = search_at + 1
         return search_res
      arr= [45,89,56,78,90,12,10,2,34,1]
      print(linear_search(arr, 12))
      print(linear_search(arr, 91))
      

      Python language logo
      Linear Search

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.