Like Walter said, the stack trace tells you what is going wrong...you are using recursion but you have the termination condition wrong, you just turtle all the way down (until you run out of stack space).
This jumped out at me:
The insert function takes a BSTNode3 node parameter.
But what is the *very first* thing insert does? This:
node=root;
So, you pass insert a node, but you immediately ignore that value and replace it with root. That sounds like a good recipe for infinite recursion to me. I don't know if just commenting out that 1 line will fix everything, but it's a start. Whatever you do...DON'T PUT IT BACK IN if something else goes wrong.
James Bond
2012-04-19 00:48:29 UTC
Why dont you mark the lines where you are getting error.
I am sure I have supplied a version of working code recently which successfully inserted nodes into BST.
anonymous
2012-04-18 23:23:19 UTC
You must not be checking it properly. Your error shows that you are going in recursion too deep which shouldn't be happening. I may look at it if you paste your code here: http://pastebin.com/ I do not want to read this code in YA because the formatting is not right. Make sure you select Java as the language.
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.