选择算法实现

时间:2015-02-03 14:36:02

标签: algorithm

我已实施"选择"算法在"算法导论"由科尔门。该算法返回数组中的第i个最小元素。我的代码适用于相当大的输入说" 36000"但如果我为大数字运行相同的代码说1000000我得到stackoverflow错误。但是根据我的说法,数字并不是那么大,以至于递归导致stackoverflow。对此有任何启发都会有很大的帮助

这是我的代码的链接。

" https://github.com/ChandanBP/MyProjects/blob/master/Select%20Algorithm"

这是我得到的例外。

Exception in thread "main" java.lang.StackOverflowError
    at Chap3.Selection.divide(Selection.java:42)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)
    at Chap3.Selection.divide(Selection.java:53)

提前致谢

0 个答案:

没有答案