Skip to content

Instantly share code, notes, and snippets.

@DiegoGallegos4
Created April 9, 2019 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DiegoGallegos4/098111c28bfa62cf23f886d04972bb4c to your computer and use it in GitHub Desktop.
Save DiegoGallegos4/098111c28bfa62cf23f886d04972bb4c to your computer and use it in GitHub Desktop.
Linear Search
def linear_search(A, k):
"""
Args:
A array: array with n elements
Returns
index i where A[i] = k, if there is not such i, then NOT_FOUND
"""
for (index, item) in enumerate(A):
if item == k:
return index
return "NOT_FOUND"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment