```
bool isValidBST(struct TreeNode* root) {
if (NULL == root)
return true;
if (NULL != root->left)
{
struct TreeNode* current = root->left;
while (current->right != NULL)
{
current = current->right;
}
if (current->val >= root->val)
{
return false;
}
}
if (NULL != root->right)
{
struct TreeNode* current = root->right;
while (NULL != current->left)
{
current = current->left;
}
if ( current->val <= root->val)
{
return false;
}
}
if ( !isValidBST(root->left))
{
return false;
}
if (!isValidBST(root->right))
{
return false;
}
return true;
```

}