- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hi! (Wave)
We have an $\text{AVL tree}$ and we are given a key $r$. I want to write an algorithm that finds the depth and height of the node, of which the key is $r$.
So, do we have to compare the key of the root with the key $r$ and if it is greater we will have to continue at the left subtree to find the element with the key $r$ and if it is smaller we will look at the right subtree?
If the root has the key $r$, the depth will be equal to $0$, right? How could we then find the height? (Thinking)
We have an $\text{AVL tree}$ and we are given a key $r$. I want to write an algorithm that finds the depth and height of the node, of which the key is $r$.
So, do we have to compare the key of the root with the key $r$ and if it is greater we will have to continue at the left subtree to find the element with the key $r$ and if it is smaller we will look at the right subtree?
If the root has the key $r$, the depth will be equal to $0$, right? How could we then find the height? (Thinking)