Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

O(1) Delete operation

Is there any data structure or variation of existing data structure that offers O(1) or constant time complexity for delete operation ?

I know hash table can do it. But I am modifying hash table where, we can get all the the keys without going through all the buckets and in order to do so I am storing every key in another linked list and at the time when I add it to hash table. So I can get all the keys in quick.

like image 331
slonkar Avatar asked Apr 27 '26 11:04

slonkar


1 Answers

What about HashSets? They offer constant time performance for add/remove/contains/size.

In java, it is called a HashSet

like image 124
DKT Avatar answered Apr 30 '26 20:04

DKT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!