This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
NewerOlder