Memory Complexity For Recursive Functions

GangstaGraham Source

What is the memory complexity of the following function?

def remove_nodes_with_value_recursive(head,x):
  if not head:
    return = remove_nodes_with_value_recursive(, x)
  return if head.val is x else head

My guess is O(n) because N recursive calls are made, so it adds those parameters N times to the stack. Is that correct? If not, please explain why.



comments powered by Disqus