Click here to Skip to main content
15,915,703 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using following aproach to make a BST


i am writing a menu driven program to insert, delete and search a word in the
dictionary.

C++
typedef struct node
{
    String word;
    String Meaning;
    struct node *left;
    struct node *right;
    struct node *parent;
};


The tree itself is represented by a pointer to the root node of the
tree. The word/meaning field stores the word corresponding its meaning of
this dictionary; the left and right pointers point to the left and right children
of this node respectively while parent points to the parent of this node (they
will take value NULL if these nodes do not exist)

so how i should store the word from a txt file to this tree.
Posted
Updated 10-Sep-14 19:27pm
v3

Hmm, you don't really need the parent member.

For more info, read this article (or others you might find)
Binary Trees in C++: Part 1[^]
 
Share this answer
 
Then you just need to arrange the nodes in the correct order.
Unless it is an exercise, you may also consider using std::map<string, string> or std::unordered_map<string, string>.
 
Share this answer
 
Comments
pi236 10-Sep-14 7:36am    
if i have to do it in c language then what?
CPallini 10-Sep-14 8:07am    
Then I suggest you to correctly TAG your question (and ignore my suggestion on using STL containers) :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900