In computer science, the Fibonacci search technique is a method of searching a sorted array using a divide and conquer algorithm that narrows down possible locations with the aid of Fibonacci numbers. (Wikipedia)
pip install allalgorithms
from allalgorithms.searches import fibonacci_search
arr = [-2, 1, 2, 7, 10, 77]
print(fibonacci_search(arr, 7))
# -> 3
print(fibonacci_search(arr, 3))
# -> None
Return array index if its found, otherwise returns
None
array
: Sorted Arrayquery
: Element to search for in the array