Josh Haverford wrote:
i am having trouble doing this - any suggestions?
Paul Clapham wrote:I'm confused about what you expect that line of code to do:
What that does (or would do if it compiled) is this:
Assign null to the test.next variable Call deleteLeaves(null)
Personally I wouldn't write that line of code, since it's rather obscure. If I wanted to do those two things I would write the appropriate two lines of code to do them. (But I suspect you don't quite want to do those two things.)
Stephan van Hulst wrote:I'll start you off:
Stephan van Hulst wrote:Yes, you will have to repeat the process for the right leaf. Also, if the left or right node you are considering is not a leaf, it means it is a root of a subtree, which contains leaves you may want to delete.
I might as well show you the final solution now. Let us know whether you understand it.
[edited 10.000 times for typos, arghghgh]