I was looking for a data structure with delete o(1) and random access o(1) for my project. Could anybody help ?
我正在为我的项目寻找一个删除o(1)和随机访问o(1)的数据结构。有人可以帮忙吗?
2 个解决方案
#1
1
If you insist on those complexities and you don't have to release memory in the table as soon as keys are deleted, then you can use dynamic perfect hashing.
如果您坚持这些复杂性,并且只要删除键就不必在表中释放内存,那么您可以使用动态完美散列。
It's a little complicated: https://en.wikipedia.org/wiki/Dynamic_perfect_hashing
这有点复杂:https://en.wikipedia.org/wiki/Dynamic_perfect_hashing
To get O(1) deletes you'll have to defer any rehashes caused by delete until the next insert.
要获得O(1)删除,您必须将删除引起的任何重新推迟推迟到下一次插入。
#2
0
You can use hash tables with an average O(1) but worst case O(n)
您可以使用平均O(1)但最差情况为O(n)的哈希表
#1
1
If you insist on those complexities and you don't have to release memory in the table as soon as keys are deleted, then you can use dynamic perfect hashing.
如果您坚持这些复杂性,并且只要删除键就不必在表中释放内存,那么您可以使用动态完美散列。
It's a little complicated: https://en.wikipedia.org/wiki/Dynamic_perfect_hashing
这有点复杂:https://en.wikipedia.org/wiki/Dynamic_perfect_hashing
To get O(1) deletes you'll have to defer any rehashes caused by delete until the next insert.
要获得O(1)删除,您必须将删除引起的任何重新推迟推迟到下一次插入。
#2
0
You can use hash tables with an average O(1) but worst case O(n)
您可以使用平均O(1)但最差情况为O(n)的哈希表