Answer: Option D
Please explain following binary search tree case study
Suppose that a binary search tree stores, at each node, u, the height, u.height, of the subtree rooted at u, and the size, u.size of the subtree rooted at u.
1. Show how, if we perform a left rotation at u, then these two quantities can be updated, in constant time, for all nodes affected by the rotation.
2. Show how, if we perform a right rotation at u, then these two quantities can be updated, in constant time, for all nodes affected by the rotation.
3. Explain why the same result is not possible if we try to also store the depth, u.depth, of each node u.
Answer: Option A
The given function will return the height of the tree.
1) It is done recursivly, the finction having N1, N2 which are again call
2)N1 will receive the height the left sub tree
3)N2 will receive the height of the right sub tree
4)Finally return statement is identifying the maximun value among N1 and max+1 to the previous call.
5)T will be NULL onely when the tree is empty. when come to the leaf node at leaf level the value -1 will be returned.
6)Finally the function will retrn the hieght of the tree, which is nothin the tree.