How many ways can you insert a series of values into a BST to form a specific tree?
问题 This earlier question asked how many ways there were to insert the values 1 - 7 into a binary search tree that would result in the following tree: 4 / \ 2 6 / \ / \ 1 3 5 7 (The answer is 80, by the way). Suppose more generally that you're given an arbitrary BST holding some set of values and want to know how many possible ways there are to insert those values into a BST that would end up producing the resulting tree. Is there an efficient algorithm for determining this? Thanks! 回答1: We can