Skip to content

Instantly share code, notes, and snippets.

@drewxa
Last active March 17, 2018 14:00
Show Gist options
  • Save drewxa/e601818ee7757e930bdd10245f385437 to your computer and use it in GitHub Desktop.
Save drewxa/e601818ee7757e930bdd10245f385437 to your computer and use it in GitHub Desktop.
struct Node
{
Node* Parent;
Node* Left;
Node* Right;
T Value;
};
template <class T>
bool isBST(Node<T>* root);
int main()
{
Node<int>* root = new Node<int>();
Node<int>* left = new Node<int>();
Node<int>* right = new Node<int>();
root->Left = left;
root->Right = right;
root->Data = 0;
left->Data = -1;
right->Data = 2;
std::cout << std::boolalpha << isBST(root); // true
left->Data = 2;
right->Data = -2;
std::cout << std::boolalpha << isBST(root); // false
delete left;
delete right;
delete root;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment