I am to find the time complexity of my algorithm and I found one method here.
However I am really not sure about it correctness thus I would like to check it.
There is my algorithm (N is a set (len(N) is constant) and C is a number):
def f(N, C, k = 0):
if C < 0:
return 0
if C == 0:
return 1
if not N:
return 0
i = 0
for l in N:
if l >= k:
i += f(N, C - liczba, liczba)
return i
And to my mind time complexity is equal to:
a+b+c+d+len(N)*C where a, b, c, d are constants.
f
. (By the way, shouldliczba
bel
?) – David Richerby Jan 15 '17 at 11:30