最好的Java集合来创建一个单词搜索树? [英] Best Java collection to create a word search tree?

查看:126
本文介绍了最好的Java集合来创建一个单词搜索树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始一个新的应用程序来搜索一个特定术语最多12000个项目的文本文件,并且还允许指定深度。



我的应用程序要求如下:

一个单词搜索树,允许:



1.分析文本文件并构建树。

2.允许指定深度

3.在树中搜索给定的术语。



什么规范说它必须是一个单词搜索树,但我怎么开始这个项目。我在想用相关的方法和一个搜索程序创建一个二叉树类来解析文本文件并允许搜索。你认为在这种情况下最合适的方法是什么?

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?

推荐答案

感谢你澄清这个问题。在这种情况下,您确实需要实现一种或另一种搜索树

http://en.wikipedia.org/wiki/Search_tree [ ^ ],

http://www.drdobbs .com / database / ternary-search-trees / 184410528 [ ^ ]。



为了节省空间和简化,三元搜索树二元搜索可以推荐树

http://en.wikipedia.org/wiki/Ternary_search_tree [ ^ ],

http:// en。 wikipedia.org/wiki/Binary_search_tree [ ^ ]。



由于文本可能比较大,而且你需要将所有数据都放在内存中,空间效率是重要的标准,即使算法的速度不是非常最大化。搜索的时间复杂度当然是O(log n)(参见 http://en.wikipedia.org/wiki/Big_O_notation [ ^ ])。节点和搜索的排列是根据字符串比较操作完成的。



由于树结构和基于树的搜索在计算机科学中是非常基础的,你会发现许多实现:

http://bit.ly/XExXbv [ ^ ],

http:/ /bit.ly/XExQNc [ ^ ]。



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


这篇关于最好的Java集合来创建一个单词搜索树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆