Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm starting a new application to search a text file with up to 12000 items for a given term and also allow a depth to be specified.

My application requirements are as folllows:
A word search tree that allows:

1.Parse a text file and build the tree.
2. Allow a depth to be specified
3. Search the tree for a given term.

What the spec says is that it has to be a word search tree but how would I start this project.I'm thinking create a binary tree class with the relevant methods and a search program to parse the text file and allow a search.What do you think would be the most suited approach in this situation?
Posted
Updated 15-Mar-13 2:47am
v2
Comments
Sergey Alexandrovich Kryukov 14-Mar-13 22:00pm    
Why do you think that the tree is the best method? Could you describe the problem, more or less formally? If you need to find anything in the file, you don't need a tree, but perhaps you need to perform the search in the tree? You need to describe the scenario...
—SA
[no name] 15-Mar-13 8:45am    
Hi Sergey,
My application requirements are as folllows:
A word search tree that allows:

1.Parse a text file and build the tree.
2. Allow a depth to be specified
3. Search the tree for a given term.

What the spec says is that it has to be a word search tree but how would I start this project.I'm thinking create a binary tree class with the relevant methods and a search program to parse the text file and allow a search.What do you think would be the most suited approach in this situation?

1 solution

Thank you for clarification of the question. In this case, you really need to implement one or another kind of a search tree:
http://en.wikipedia.org/wiki/Search_tree[^],
http://www.drdobbs.com/database/ternary-search-trees/184410528[^].

For space efficiency and simplicity, a ternary search tree or binary search tree could be recommended:
http://en.wikipedia.org/wiki/Ternary_search_tree[^],
http://en.wikipedia.org/wiki/Binary_search_tree[^].

As the text can be relatively big, and you need to place all data in memory, space efficiency is important criterion, even though the speed of the algorithm is not the very maximum. The time complexity of search is of course O(log n) (see http://en.wikipedia.org/wiki/Big_O_notation[^]). The arrangement of nodes and search is done according string comparison operation.

As the tree structures and tree-based search are very fundamental in computer science, you will find many implementations:
http://bit.ly/XExXbv[^],
http://bit.ly/XExQNc[^].

—SA
 
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