iman12
iman12

Reputation: 1

A Data structure with delete o(1) and random access o(1)

I was looking for a data structure with delete o(1) and random access o(1) for my project. Could anybody help ?

Upvotes: 0

Views: 844

Answers (2)

Matt Timmermans
Matt Timmermans

Reputation: 59144

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

To get O(1) deletes you'll have to defer any rehashes caused by delete until the next insert.

Upvotes: 1

kkica
kkica

Reputation: 4104

You can use hash tables with an average O(1) but worst case O(n)

Upvotes: 0

Related Questions