We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b1b4bda commit 5db8309Copy full SHA for 5db8309
LinearSearch.py
@@ -0,0 +1,28 @@
1
+def search_linear(x,y):
2
+ n = len( x )
3
+ for i in range(n):
4
+ if theValue[i] == y:
5
+ return True
6
+ return false
7
+
8
+def sequentialSearch(alist, item):
9
+ pos = 0
10
+ found = False
11
12
+ while pos < len(alist) and not found:
13
14
+ if alist[pos] == item:
15
+ found = True
16
+ print("Found")
17
+ else:
18
+ pos = pos+1
19
+ if found == False:
20
+ print("Not found")
21
+ return found
22
23
+print("Enter numbers seprated by space")
24
+s = input()
25
+numbers = list(map(int, s.split()))
26
+trgt =int( input('enter a single number to be found in the list '))
27
+sequentialSearch(numbers, trgt)
28
0 commit comments