Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java Trees binary search
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 14-Mar-13 14:01pm
Edited 15-Mar-13 3:47am
v2
Comments
Sergey Alexandrovich Kryukov at 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
johngorman1 at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 320
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 184
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 15 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100