Find optimal binary search tree structure

非 Y 不嫁゛ 提交于 2019-12-08 04:37:38

问题


In reference to the problem HERE, how can we find the structure of optimal binary search tree. Author says:

In the above solutions, we have computed optimal cost only. The solutions can be easily modified to store the structure of BSTs also. We can create another auxiliary array of size n to store the structure of tree. All we need to do is, store the chosen ‘r’ in the innermost loop.

But above is not clear to me. Talking about loops, we start with chains of length 2,3 .. and so on. So let us say we store the value or r for chain of length 3 and onwards. How does it depict or help in getting tree structure ?

来源:https://stackoverflow.com/questions/28471909/find-optimal-binary-search-tree-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!