Last active
March 17, 2018 14:00
-
-
Save drewxa/e601818ee7757e930bdd10245f385437 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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