@fernandob/

Algorithms BigO

Python

No description

fork
loading
Files
  • main.py
  • binary_search.py
  • linear_search.py
  • recursive_binary_search.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from linear_search import *
from binary_search import *
from recursive_binary_search import *

def verify(index):
    if index != None:
        print("Target found at index: ", index)
    else:
        print("Target not found in list")

def verify_recursive(result):
    print("Target found : ", result)

numbers = [1,2,3,4,5,6,7,8,9,10]

linear_search_result = linear_search(numbers, 5) 
binary_search_result = binary_search(numbers, 5) # HAS TO BE SORTED!
recursive_binary_search_result = recursive_binary_search(numbers, 11)

verify_recursive(recursive_binary_search_result)