BST:
BST has the advantages of both array and linked list: it can do binary search and also it is of dynamic size.
BST allows fast enumeration of the items in key order.
Lookup algorithms get more complicated when there may be multiple items with the same key.
support range query
Hashtable:
lookup operation in hashtable is constant.
cannot provide ordering
do not support range query
Array:
allow random access
change is hard: need to change the whole structure
LinkedList:
allow easy insertion, extension, resize.
do not support random access
change is easy: just change the pointer
本文对比了四种数据结构:BST、Hashtable、Array和LinkedList,阐述了它们各自的优势、缺点以及应用场景。BST支持快速按键顺序枚举、范围查询,但查找复杂度增加;Hashtable提供常数时间查找,不支持排序和范围查询;Array允许随机访问,修改困难;而LinkedList易于插入、扩展和调整大小,但不支持随机访问。
1万+

被折叠的 条评论
为什么被折叠?



