2
2
3
3
4
4
global steps
5
- steps = 0
5
+ steps : int = 0
6
6
7
7
print ("[G] Generating List " )
8
- test_arr = [x for x in range (1 ,1_00_000_000 + 1 )]
8
+ test_arr : list = [x for x in range (1 ,1_00_000_000 + 1 )]
9
9
print ("[EG] List generated successfully" )
10
10
11
11
12
- def bin_search (arr , tar , end , start = 0 ):
12
+ def bin_search (arr : list , tar : int , end : int , start : int = 0 ):
13
13
"""
14
14
arr = array for search
15
15
tar = target number for search
16
- start = location for start
16
+ start = location for the start
17
17
end = end location of search <len(arr)>
18
18
"""
19
19
global steps
@@ -32,7 +32,7 @@ def bin_search(arr, tar, end, start=0):
32
32
33
33
def linear_search (arr , tar ):
34
34
start = time .time () * 1000
35
- for index ,value in enumerate (arr ):
35
+ for index , value in enumerate (arr ):
36
36
if value == tar :
37
37
end = (time .time () * 1000 )
38
38
return f"Found { value } Using linear algorithm, in { index + 1 } steps, { end - start } ms"
@@ -47,4 +47,4 @@ def linear_search(arr, tar):
47
47
48
48
49
49
result = linear_search (arr = test_arr , tar = 9_9999_999 )
50
- print (result )
50
+ print (result )
0 commit comments