Design DP for optimal BST given key probabilities
Analyze the design dp for optimal bst given key probabilities.
Examples
Input: "test_input_1"
Output: "output_1"
Input: "test_input_2"
Output: "output_2"
Hints
Start by understanding the structure of a BST and how it relates to the optimal BST problem. Recall that the goal is to minimize the expected search cost given key probabilities.
Consider how dynamic programming can be used to break down the problem into smaller subproblems. Think about how the optimal BST for a set of keys can be constructed from optimal BSTs of smaller subsets.
Focus on the recurrence relation for the optimal BST problem. How can you define the cost of a subtree rooted at a particular key, and how does this relate to the costs of its left and right subtrees?
Design DP for optimal BST given key probabilities
Analyze the design dp for optimal bst given key probabilities.