문제

Assume that a BST was built purely with insertions and all key orderings are equally likely. You are given the root of a particular tree, what is the probability that the given tree was built?

올바른 솔루션이 없습니다

다른 팁

The answer to this question can be calculated recursively.

prob. of tree = prob. of root being chosen correctly * prob. of left subtree being formed * prob. of right subtree

we now only need to find the prob. of root being chosen correctly, which is 1/num. of nodes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top