I have a working snippet to use for a regular tree comprising nodes. Now I just need to fiddle with it to work for 2-3-4 trees, which should be easier, since ...
I'm trying to know whether my code is right or wrong with your help, because sadly I can't run it to check.
There are no compile errors. What I'm trying to ...
No this wasn't specified and so I noticed I was missing that thanks for pointing it out.. method seems to work now. Having troubles with the depth one now.. i just don't understand how to set it up recursively... to calculate the depth of the BST shouldn't I just have to call the method to go left and right over and ...
With a recursive height function so simple, I'm pretty sure mine is correct. I must have a problem in the add() method that is placing my nodes in the wrong place, giving me a height of 9 instead of a height of 5 as its supposed to be. Does anyone see any problem in my add method?
I have some idea here. I am trying to code it in. I am traversing the tree as edward suggested. Here's what I think I should do : - Initialize height to 0, numberOfBranches to 0. - Start traversing from the node. - If root has no children, return height as 0. - Else starting with one of root's children, start ...
Tracking the height as I insert seems like an easy alternative, but i must write a stand-alone method which doesn't depend on any other. I have a vague idea of how to do it: I have to ints, one which carries the temporal height (let's say h) and the other which has the maximum height (mh). I start going down, always ...