【发布时间】:2021-12-25 05:43:34
【问题描述】:
我一直在阅读这个主题,到目前为止,从我对添加、删除和搜索操作的理解来看,HashSet 的时间复杂度为 O(1) 更快,而 TreeSet 的时间复杂度为 O(log n)。在遍历元素时,HashSet 和 TreeSet 的时间复杂度都是 O(n)。
那么当 TreeSet 比 HashSet 快时,什么是用例?
【问题讨论】:
-
您为什么认为存在这样的用例?
标签: java data-structures computer-science