Given a list, say 'x' is in a length of n, what's the time complexity of the following algorithm?
def foo(x):
n = len(x)
if n <= 1:
return 17
return foo(x[:n//2]) + foo(x[n//2:])
The answer is:
O(n log n)
But I can't figure out why? I struggle to figure the last row where we use recursion, I know that it's cutting the length of the list in half each time so its O(log n), but it add's to each iteration the other recursion which is also O(log n) each time so I though its O(log n log n) but unfortunately its not.