diff --git a/bst.cpp b/bst.cpp new file mode 100644 index 0000000..421a254 --- /dev/null +++ b/bst.cpp @@ -0,0 +1,31 @@ +//Binary tree for C++ +#include +using namespace std; + +class Node { + public: + int data; + Node* left; + Node* right; + + // Val is the key or the value that + // has to be added to the data part + Node(int val) + { + data = val; + // Left and right child for node + // will be initialized to null + left = NULL; + right = NULL; + } +}; + +int main() +{ + /*create root*/ + Node* root = new Node(1); + root->left = new Node(2); + root->right = new Node(3); + root->left->left = new Node(4); + return 0; +}