美文网首页
RecursionError: maximum recursio

RecursionError: maximum recursio

作者: candice0430 | 来源:发表于2021-12-22 18:37 被阅读0次

When you execute a recursive function in Python on a large input ( > 10^4), you might encounter a “maximum recursion depth exceeded error”. This is a common error when executing algorithms such as DFS, factorial, etc. on large inputs. This is also common in competitive programming on multiple platforms when you are trying to run a recursive algorithm on various test cases. 

例如:

解决方案:Using the setrecursionlimit() method, we can increase the recursion limit and the program can be executed without errors even on large inputs.

import sys

sys.setrecursionlimit(10**6)

相关文章

网友评论

      本文标题:RecursionError: maximum recursio

      本文链接:https://www.haomeiwen.com/subject/gytcqrtx.html