数据结构求助,关于Binary search tree的题目
比如:
输入3 1 4 5 2
生成的树为:
3
|\
1 4
\ \
2 5
输入3 4 1 2 5或3 4 5 1 2也可以生成同一棵BST。
要求是,先输入一组数(n个),然后再输入L组数(每组n个数字不变,但顺序不同),判断是否能够生成同一棵树,是输出YES,否输出NO。
本人小白刚刚起步,想不到什么好的算法啊,请各位高手帮帮忙!
相关推荐
陈越、何钦铭-数据结构作业16:Complete Binary Search Tree完全二叉搜索树
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than or equal to the node's key. Both the left and right subtrees must also be binary search trees. A Complete Binary Tree (CBT) is a tree that is completely filled, with the possible exception of the bottom level, which is filled from left to right. Now given a sequence of distinct non-negative integer keys, a unique BST can be constructed if it is required that the tree must also be a CBT. You are supposed to output the level order traversal sequence of this BST.
Binary Search Tree
Binary Search Tree 利用C++實現 Binary Search Tree
binary-search-tree-AloWarrior2000:GitHub Classroom创建的binary-search-tree-AloWarrior2000
binary-search-tree-AloWarrior2000:GitHub Classroom创建的binary-search-tree-AloWarrior2000
binary-search-tree-angelmotta:由GitHub Classroom创建的binary-search-tree-angelmotta
binary-search-tree-angelmotta:由GitHub Classroom创建的binary-search-tree-angelmotta
leetcode的题目:Balanced Binary Tree
leetcode的题目:Balanced Binary Tree


