The way in which we come up with subproblems is to choose a root for a set of vertices and then apply the same algorithm for the sets to the left and right of the root, as per the BST property.

The straightforward DP algorithm for this problem which determines the optimal choice of root for each set of elements operates in $O(n^3)$ time.

As with all other DP algorithms, there is a reconstruction step that is required to construct the tree from the computed set of optimal search times.

However, upon storing more information about the different cases and using a result from the monotonicity property, we can come up with a $O(n^2)$ algorithm.