I was solving one problem on codechef and I used recursion, when I am submitted it's solution in c and it was a successful submission. But when I tried to do it in java I got NZEC error. does it mean c has higher stack limit for executing recursive calls than java. asked 24 Feb '16, 18:18 ![]()
|
Can you provide link to Java code? answered 24 Feb '16, 18:26 ![]()
(24 Feb '16, 18:35)
|
Yes Stack limit in Java is less than that of C. I also faced some problems initially. Anyways you can increase the stack limit in Java by using multi-threading. Create thread for each recursion which will have it own stack limit.
Write the above code snippet in main Function. You can see the sample solution here answered 24 Feb '16, 23:11 ![]()
does this technique compromises the performance??
(24 Feb '16, 23:13)
That link is not accessible to me, It says "403 Access denied".
(24 Feb '16, 23:16)
No it doesn't compromise with the performance.You can view any of my recent submission. Here is other sample solution.
(24 Feb '16, 23:31)
Thanks @ankurverma1994
(25 Feb '16, 00:31)
If this answers your question then mark it as accepted and close the question.
(25 Feb '16, 00:36)
Isn't there any limit to number of threads that can execute simultaneously??
(25 Feb '16, 08:53)
There is limit to create the number of threads. I don't know exactly how much. You can google it to learn more about it. The code snippet that I gave you, will not give StackOverflowError in Competitive Programming if your algorithm is correct.
(25 Feb '16, 11:55)
showing 5 of 7
show all
|
Your Question should be treated as compiler and OS specific. The Standard (language) does'n mandate the min/max stack size and doesn't specifies the location of the stack memory. answered 31 Mar '16, 03:31 ![]()
|