Here is my whole program: https://pastebin.com/dqqGn0rn. Here is the part of the program where the overflow happens: https://pastebin.com/JCCj8knQ. I get this error on a test with a million nodes: https://pastebin.com/eCxBK4pf. Is perhaps the language is use (Java) the problem? Can I fix this without making it iteratively and without changing my language?↵
↵
EDIT: also, for the test on which it failes it says: time: 763 ms., memory: 252648 KB
↵
EDIT: also, for the test on which it failes it says: time: 763 ms., memory: 252648 KB