blakeembrey/code-problems — pull request #100 by caoglish (2014-02-03 03:05:50+00:00)
Title: binary-search-tree-check(js) using In-Order Traversal method

according to article in http://www.geeksforgeeks.org/a-program-to-check-if-a-binary-tree-is-bst-or-not/

the current binary search tree check using the METHOD 1 (Simple but Wrong). if tree is like:
```javascript
var bstfalse = {
value: 3,
left: {
value: 2,
right: {
value: 10
}
},
right: {
value: 5
}
};
```
The current result is true,which should be false;

so I rewrite the code regarding the article and using METHOD 4(Using In-Order Traversal)

```javascript
module.exports = function(bst) {
if (!bst || bst.value === null) {
return false;
}

var prev;

return (function isBst(root) {
if ( !! root) {
if (!isBst(root.left)) {
return false;
}

if (prev && prev.value >= root.value) {
return false;
}

prev = root;

return isBst(root.right);
}

return true;
})(bst);
};

```