Unique Binary Search Trees II

来源:互联网 发布:世界银行官方数据网站 编辑:程序博客网 时间:2024/06/06 02:18

Given n, generate all structurally unique BST’s (binary search trees) that store values 1…n.

For example,
Given n = 3, your program should return all 5 unique BST’s shown below.

   1         3     3      2      1    \       /     /      / \      \     3     2     1      1   3      2    /     /       \                 \   2     1         2                 3
0 0
原创粉丝点击