Skip to content

Commit 987f8cd

Browse files
committed
Searching
1 parent 4fff91a commit 987f8cd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

searching/linearsearch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def linearsearch(A, key):
2+
index = 0
3+
while index < len(A):
4+
if A[index] == key :
5+
return index
6+
index = index + 1
7+
return -1
8+
9+
A = [84, 21, 47, 96, 15]
10+
found = linearsearch(A,96)
11+
print('Result:',found)

0 commit comments

Comments
 (0)