LeetCode - Validate Binary Search Tree
Judge Rules:
1. the maximum value of left subtree < root's value
2. the minimum value of right subtree > root's value
3. both the left and right subtrees are meet the above conditions.
4* empty tree is valid!
http://www.cnblogs.com/remlostime/archive/2012/11/16/2772629.html
C header file<limits.h> defines as follows:
#define INT_MAX 2147483647
#define INT_MIN (-INT_MAX-1)
Attach:
OJ's Binary Tree Serialization:
The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below.
Here's an example:
1
/ \
2 3
/
4
\
5
The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}"
.
posted on 2013-04-16 20:46 highstar88 阅读(97) 评论(0) 编辑 收藏 举报