Created
December 16, 2022 04:44
-
-
Save pycoders0000/53517f35b27c28d7e098709546eb516c to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
# @Date : 2022-07-26 07:14:08 | |
# @Author : pycoder.py | |
# @GitHub : (https://github.com/pycoders0000) | |
# @Twitter : (https://twitter.com/pycoder0000) | |
# @Instagram : (https://www.instagram.com/pycoder.py/) | |
# @Version : 1.0.0 | |
def search(cards, query): | |
position = 0 | |
while position < len(cards): | |
if cards[position] == query: | |
return position | |
position += 1 | |
return -1 | |
search([-5, 7, 3, 2, 9, -2, -7, -1, 0], 2) | |
# Sequential Search algorithm is a very simple algorithm | |
# that is used to search for an element in a list. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment