0
$\begingroup$

I'm going over past exam papers with this question: enter image description here

The answer to a). will be (height of 5):

enter image description here

For b.): I assume the height function will be to find the height of the tree. So, I will have to compare right and left sub-trees and get the tallest subtree + 1(root node) = Height

But what happens if there is a duplicate node? I'm a novice java coder but if I'm right, on this code it will just ignore the duplicate node and return the result of the tree before attempting to add the duplicate node.

$\endgroup$
  • $\begingroup$ Yes, it just ignores them $\endgroup$ – Azmisov Apr 29 at 18:04
  • $\begingroup$ Programming questions are off-topic here. $\endgroup$ – Yuval Filmus May 1 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.