Created
April 9, 2019 17:43
-
-
Save DiegoGallegos4/098111c28bfa62cf23f886d04972bb4c to your computer and use it in GitHub Desktop.
Linear Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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