Linear Search

    0

    0

    Aakanksha Priya

    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))
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.