Recursion
Page content
- Recursion isn’t a strong Python feature due to the inherent recursion limit.
def sum(items):
head, *tail = items
return head + sum(tail) if tail else head
- Storing partial results would have done no good for such recursive algorithms as quicksort, backtracking, and DFS because all the recursive calls made in these algorithms have distinct parameter values. It doesn’t pay to store something you will use once and never refer to again.