Recent Entries 4
- debug critical 112d agoWhat is a StackOverflowError?What is a `StackOverflowError`, what causes it, and how should I deal with them?
- snippet critical 112d agoWhat is the maximum recursion depth, and how to increase it?I have this tail recursive function here: ``` def recursive_function(n, sum): if n < 1: return sum else: return recursive_function(n-1, sum+n) c = 998 print(recursive_function(c, 0)) ``` It works up to `n=997`, then it just breaks and spits out a `RecursionError: maximum recursion depth exceeded in comparison`. Is this just a stack overflow? Is there a way to get around it?
- snippet critical 112d agoWhat is the maximum recursion depth, and how to increase it?I have this tail recursive function here: ``` def recursive_function(n, sum): if n < 1: return sum else: return recursive_function(n-1, sum+n) c = 998 print(recursive_function(c, 0)) ``` It works up to `n=997`, then it just breaks and spits out a `RecursionError: maximum recursion depth exceeded in comparison`. Is this just a stack overflow? Is there a way to get around it?
- gotcha major 124d agoDFS on a graph: use iterative stack to avoid call stack overflow on deep graphsRecursive DFS on a graph with 10,000+ nodes can hit JavaScript's call stack limit (~10k-15k frames). Recursive DFS is also harder to pause or serialize for tasks like pathfinding with backtracking.