I have looked high and low on the web for the insertion algorithm for a BST. Can anyone either point me in the right direction or provide one for me. Thanks!!
Printable View
I have looked high and low on the web for the insertion algorithm for a BST. Can anyone either point me in the right direction or provide one for me. Thanks!!
1) compare new node vs. root node
2) LOOP: if less, return node->left. if greater, return node->right.
Test for a terminating case w/ each iteration.
3) Now you have a pointer to where the node is supposed to be inserted.
Make the proper pointer assignments to make the insertion.
how do i initalize the first node, use a constructer in my node declaration to set the pointers *left and *right to NULL, then in my gooey of the "insertNode" alg, do i set "node Newnode = new node"?