Should i switch to c++,Recursion problem in java,stack overflow,Whats the solution ??

I was doing question
Which is the simplest question in graph and based on dfs.
I coded it in java and I also know that In java stack space is very less.So I am getting NZEC error.

As i started practicing graph.And A lot of graph question i will do in java So again i will get NZEC.
So its my serious problem. Plz Tell me

  1. Should i switch to c++(which i don’t want )? :frowning:
  2. Should i convert recursion procedure into iterative in java(lots of graph question are very touch through iterative procedure)? :frowning:
  3. Any other alternative suggestion plz…

I still want recursive method and want to submit it in java.
PLZ help…

My solution to the above problem in which i got NZEC error b/c of using recursion in java :

check this link

Any link will be very helpful.

Can anybody tell me how to apply mutithreading in java??

Plz any one help:(:frowning:

Can you tell me how to go from one thread to another while writing code??

Use your own external stack instead of recursion…