I need help with the algorithm for inserting a text file into a Binary Tree, the pseudo-code will do just fine, or even the C++ code if anyone feels frisky... thanks guys.
This is a discussion on Help with Algorithm for inserting data into Binary Tree within the C++ Programming forums, part of the General Programming Boards category; I need help with the algorithm for inserting a text file into a Binary Tree, the pseudo-code will do just ...
I need help with the algorithm for inserting a text file into a Binary Tree, the pseudo-code will do just fine, or even the C++ code if anyone feels frisky... thanks guys.
If you need this kind of information, there are hundreds of binary tree tutorials and bits of example code all around the web. Why not try G O O G L E ?!Code:BinaryTree myTree; myTree.insert("I'm not feeling frisky"); myTree.insert("I'm not doing someone else's homework"); myTree.display();
Data - Object to be inserted in tree
Node - your current node oyu're in
1) Set Node to Root of tree
2) If Data.Value < Node.Value goto 3) else goto 6)
3) if Node.Left is empty, insert Data as left child of Node, stop
4) Set Node to Node.Left
5) goto 2)
6) if Node.Right is empty, insert Data as right child of Node, stop
7) Set Node to Node.Right
8) goto 2)
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.