Algorithm
Time Complexity Running time of binary search
Github
Java
Decorator Fibonacci
class MyCache(object):
def __init__(self, func):
self.func = func
self.cache = {}
print(f'In MyCache __init__ {func.__name__}')
def __call__(self, *args):
if not args in self.cache:
self.cache[args] = self.func(*args)
return self.cache[args]
@MyCache
def fib(n):
if n <=1: return 1
return fib(n - 1) + fib(n - 2)
print(fib(33))
Divide and Conquer
Maximum Subarray Sum using Divide and Conquer algorithm
Print all shortest paths between given source and destination in an undirected graph