In the code in the question, we donβt get a height of +1? height is defined as 'the length of the path from the root to the deepest node in the tree. A tree with a root (with root) with one node (root) has a depth of zero.' (Wikipedia)
if in the interrogation code, if you give the root to the tree with only 1 node, it will give a height as 1, which should be 0 ..
Please correct me if I'm wrong somewhere.
Its Me
source share