You are viewing a single comment's thread. Return to all comments →
C++ solution (without recursion) :
Node * insert(Node * root, int data) { if (!root) return new Node(data); Node* base=root, *prev; while(base) { prev=base; if (data<base->data) base=base->left; else base=base->right; } if (prev->data<data) prev->right = new Node(data); else prev->left = new Node(data); return root; }
Seems like cookies are disabled on this browser, please enable them to open this website
Binary Search Tree : Insertion
You are viewing a single comment's thread. Return to all comments →
C++ solution (without recursion) :