1 / 3
Mar 2011

Is there something like recursion limit in C/C++ as in Python (see this topic)?
Because I wrote a program and I got SIGSEGV even if I remove the array from the code (so that there is no array).
Here's the code:
link was here
You can look at the tests. In the first:

3
100000
200000
400000

I get SIGSEGV, while in the second:

4
100000
200000
300000
400000

I get AC.
So if I divide the number of "recursions" into few parts it doesn't return me SIGSEGV.
Am I thinking correctly?
If so, is there any way to increase this limit (as in Python)?

Edit: I mean, I know that I can write for example:

for(i=10000;i<=x;i+=10000)sub(i);

but I'm interested is any function (as in Python) which would do it for me.

  • created

    Mar '11
  • last reply

    Mar '11
  • 2

    replies

  • 287

    views

  • 2

    users

  • 1

    link

Recursion in c/c++ is simply limited to memory usage. it returns an error when it trys to allocate memory in an unusable memory location. There is no way to increase the usable amount of memory on SPOJ.

Pity. Nevertheless, as I said, it can be divided which I did (but the intervals had to be very small) but the fastest occurs to be the iterative way.
Thank You for the information.