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!!
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.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
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"?