Skip to content

Commit 67f26d3

Browse files
authored
Merge pull request DeepNinja07x#69 from vidhichadha2507/patch-6
linear search
2 parents 2e0eee5 + 6bc8d1b commit 67f26d3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def linearsearch(arr, x):
2+
for i in range(len(arr)):
3+
if arr[i] == x:
4+
return i
5+
return -1
6+
arr = ['t','u','t','o','r','i','a','l']
7+
x = 'a'
8+
print("element found at index "+str(linearsearch(arr,x)))

0 commit comments

Comments
 (0)