Click here to Skip to main content
15,922,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I am working on a C++ program. A part of it requires that i use binary search tree preorder of the elements. I have a string array with lines for biomedical entities. These entities need to be used after they are inserted in this bst.

Since i am not from CS background, it seemed a bit out of my bounds given the time frame i have. So if there is some snippet that can process the string array output , i can move on to further process the program of mine. So i might need two function snippets if someone can help, one would be to take this string array with 40 elements that i have and insert them in the tree as their occurrence. Second part wold be to display the preorder traversal of those nodes.

I hope i am not demanding much with c gurus over here.
Posted
Comments
newbie.cppcoder 14-Oct-11 4:53am    
Can anyone help me with this please?
Richard MacCutchan 14-Oct-11 5:21am    
You only posted this 2 hours ago; show some patience! If anyone can help then they will, in their own time. In the meantime you could spend some effort with Google looking for BST samples.

1 solution

The following link only provides Java code, but has excellent documentation:
http://en.wikipedia.org/wiki/Binary_search_tree[^]

I posted this to show you how complex a binary search tree is to implement. You implied you have a limited time frame, and therefore I have to ask: why do you need to use a BST at all? A simple list serves well enough for the purpose of storing and retrieving ordered data, and there are predefined sort functions in the Standard Template Library that you can use in case the data doesn't come in an ordered sequence.

P.S.: there actually is a link to a C++ implementation at the bottom of the page I linked above.
 
Share this answer
 
v2

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