递归代码 [英] Recursive Code

查看:63
本文介绍了递归代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个递归函数,但问题是我需要使用

非常大的数据来测试它。总是我的程序进入细分

错误。 RECURSIVE FUNCTION的问题是否附带内存

的事情?改为不递归似乎非常困难。是否有任何

的建议?

I''ve got a recursive function, but the problem is that I need to use a
very big data to test it. Always my program goes to segmentation
fault. Does the problem for RECURSIVE FUNCTION comes with memory
thing? Change to not recursive seems very difficult. Is there any
suggestion for that?

推荐答案

cp *************** @ gmail.com 写道:

我有一个递归函数,但问题是我需要使用

非常大的数据来测试它。总是我的程序进入细分

错误。 RECURSIVE FUNCTION的问题是否带有内存
I''ve got a recursive function, but the problem is that I need to use a
very big data to test it. Always my program goes to segmentation
fault. Does the problem for RECURSIVE FUNCTION comes with memory



听起来好像你在破坏内存。你可以查看你的程序

与内存检查器如valgrind

Sound like you are corrupting the memory. You can check your program
with memory checker like valgrind


的事情?改为不递归似乎非常困难。那有什么

的建议吗?
thing? Change to not recursive seems very difficult. Is there any
suggestion for that?


cp * **************@gmail.com 写道:

我有一个递归函数,但是问题是我需要使用

非常大的数据来测试它。总是我的程序进入细分

错误。 RECURSIVE FUNCTION的问题是否附带内存

的事情?改为不递归似乎非常困难。那有什么

的建议吗?
I''ve got a recursive function, but the problem is that I need to use a
very big data to test it. Always my program goes to segmentation
fault. Does the problem for RECURSIVE FUNCTION comes with memory
thing? Change to not recursive seems very difficult. Is there any
suggestion for that?



你可能用完了堆栈(递归太多)。在调试器下运行你的

应用程序并查看它失败的地方。


-

Ian Collins。

You could be running out of stack (too many recursions). Run your
application under a debugger and see where it fails.

--
Ian Collins.


6月18日下午6:01,Ian Collins< ian-n ... @ hotmail.comwrote:
On Jun 18, 6:01 pm, Ian Collins <ian-n...@hotmail.comwrote:

你可能会用完堆栈(递归太多)。在调试器下运行你的

应用程序并查看它失败的地方。
You could be running out of stack (too many recursions). Run your
application under a debugger and see where it fails.



是的。我猜它没有堆栈。但我的问题是:太难了

将代码更改为非递归。任何减少使用的建议

堆栈还是重用堆栈?

Yes. I guess it runs out of stack. But my problems are: too difficult
to change the code into non recursive. Any suggestion to reduce use
the stack or reuse the stack?


这篇关于递归代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆