Hi i have about 5 types of strings having information in each string

i need to transfer them into a binarytree so i need them in one node only

i cant work out what i have to do.. every time i add a string it adds a node i want

5 strings = 1 node ... how do i do this?

thanks!

Your question is not particularly clear. Please explain the problem scope more specifically. A binary tree has only one item in each node. A B+ tree can have multiple items in each index node. So, if you want 5 strings/items in each node, you need to implement a B+ or AVL tree. Read Knuth Volume 3, "Sorting and Searching" for good algorithms on doing this. FWIW, Knuth is the "bible" of software engineering.

well this is my classess

Like this?

class binarySearchTree
{
public:
binarySearchTree(); 


void treeInsert(treeNode *&root, string newItem, string oldItem, string ollItem, string neeItem, string hapItem);
binarySearchTree::binarySearchTree() :root(NULL)
{
}
void binarySearchTree::treeInsert(treeNode *&root, string newItem, string oldItem, string ollItem, string neeItem, string hapItem)

{
if(root == NULL)
{


root = new treeNode(newItem), (oldItem), (ollItem),  (neeItem),  (hapItem);

return;
}
else if (newItem, oldItem,  ollItem,  neeItem,  hapItem < root->data)
{
treeInsert(root->left, newItem,  oldItem,  ollItem,  neeItem,  hapItem);
}
else
{
treeInsert(root->right, newItem,  oldItem,  ollItem,  neeItem,  hapItem);
}
}//end treeInsert

"Like this?" - Not really... "This" is pretty crufty. A pointer to a reference in tht treeInsert() method? Come on. Where did you learn C++? I think that it is time that you spend a few $$ and some time with Lord Knuth, Volume 3, Sorting and Searching...

"Like this?" - Not really... "This" is pretty crufty. A pointer to a reference in tht treeInsert() method? Come on. Where did you learn C++? I think that it is time that you spend a few $$ and some time with Lord Knuth, Volume 3, Sorting and Searching...

thanks you have been a great mentor or "help"

thanks you have been a great mentor or "help"

Sorry, but sometimes I get a bit sarcastic... :-) In any case, just remember the KISS principle. There are a lot of binary tree types. Some allow only one member element per node (a proper binary tree), some that allow more than one member element per node (B+ tree - common in database systems for indexes), and then there are the insert/delete/balance algorithms. This is a complex and complicated domain which is why I referred you to Knuth, who covers all of this in Volume 3 of his seminal work "The Art of Computer Programming".

My opinion is that EVERY computer programmer should have a copy of this set on their book shelf. Also, he recently released volume 4, after about 30 years... I still have to get that one, or a complete copy of the current set. It will only set me back about $172USD on Amazon.com today... :-)

So, I just went on to Amazon.com and ordered the complete 5 volume set of volume 4 - only set me back about $80USD... :-)

im glad your sarcastic most of the times because so am i:)

im asking for help on a forum to get a faster reply then the duration of a book to get posted to my house..in programming you think logically .. am i right

Creating a B+ or AVL tree program is not trivial. Having documentation (book or online form) available is most helpful. Here is the Wikipedia link for AVL trees: http://en.wikipedia.org/wiki/AVL_tree

Note that there is a link to a C++ implementation of the algorithm at the bottom of the article.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.