Page 183 - Algorithms Notes for Professionals
P. 183

def linear_search(searchable_list, query):
           for x in searchable_list:
               if query == x:
                   return True
           return False

       linear_search(['apple', 'banana', 'carrot', 'fig', 'garlic'], 'fig') #returns True






















































































       colegiohispanomexicano.net – Algorithms Notes                                                           179
   178   179   180   181   182   183   184   185   186   187   188