Skip to content

Instantly share code, notes, and snippets.

View aahnik's full-sized avatar
🏠
something's happening!

Aahnik Daw aahnik

🏠
something's happening!
View GitHub Profile
# aahnik 2020
def recursive_binary_search(arr, lo, hi, ele):
# Returns index of ele in arr if present, else -1
# arr is our list
# lo is lower/left pointer
# hi is higher/right pointer
# ele is element to search
if hi >= lo:
# possibility that ele exists
# General Term (x ** power)/factorial(power)
# where power ranges from 0 to n-1 if the series has n terms
def factorial(num):
# recursive function
if num == 0:
# base case
return 1
else:
return num * factorial(num - 1)