Runtime exception, recursion too deep

后端 未结 12 983
余生分开走
余生分开走 2020-12-19 04:59

I converted the pseudo-code here into C#, and have it recursively repeat 10,000 times. But I get a C# runtime error, StackOverflow Exception after 9217

12条回答
  •  伪装坚强ぢ
    2020-12-19 05:45

    It's not infinite recursion obviously since it stops after 10,000 levels, but it's still not the best idea.

    Ten thousand stack levels is an awful lot - the stack is not a massive resource. You should convert it into an iterative solution.

提交回复
热议问题