Optimal binary search tree (dynamic programming)