C++ stack limit

In java, the maximum stack size was about 5000 so recursion on trees would give stackoverflow(I am talking about internal stack size), so we had to use iterative dfs.But, I have seen many solutions where in C++, we can use recursion even if number of nodes is 10^5.Is it that the recursion depth in C++ is larger than that in Java, or is it that in those problem testcases skew trees where not present and that internal stack size of C++ is the same as Java.

As to specific problems, I have seen some solutions in Wealth disparity problems of INOI practice contest., along with some other examples, the problems of which I do not remember.

Please tell as INOI is closeby and it would really help if I am able to write a recursion based dfs, not because I cannot do the iterative one but because recursion is much simpler.

For DFS a recursion depth of 10.000 each stack frame can be at most ~100 bytes.

stacks for threads are often smaller. For reference some defaults are:

  1. glibc i386, x86_64 7.4 MB

  2. Tru64 5.1 5.2 MB

  3. Cygwin 1.8 MB

  4. Solaris 7…10 1 MB

  5. MacOS X 10.5 460 KB

  6. AIX 5 98 KB

  7. OpenBSD 4.0 64 KB

  8. HP-UX 11 16 KB

Please inform me if I am worng. :slight_smile: