【leetcode】235-Lowest Common Ancestor of a Binary Search Tree

problem

235. Lowest Common Ancestor of a Binary Search Tree

 二叉搜索树的性质

Lets review properties of a BST:
.Left subtree of a node N contains nodes whose values are lesser than or equal to node N's value.
.Right subtree of a node N contains nodes whose values are greater than node N's value.
.Both left and right subtrees are also BSTs.

百科解释

二叉查找树(Binary Search Tree),(又:二叉搜索树,二叉排序树)它或者是一棵空树,或者是具有下列性质的二叉树: 
若它的左子树不空,则左子树上所有结点的值均小于它的根结点的值;
若它的右子树不空,则右子树上所有结点的值均大于它的根结点的值;
它的左、右子树也分别为二叉排序树。

参考

1. leetcode_235_Lowest Common Ancestor of a Binary Search Tree;

猜你喜欢

转载自www.cnblogs.com/happyamyhope/p/10394998.html