insert, delete, max in O(1)

Viewed 38751

Can someone tell me which data structure supports insert/delete/maximum operation in O(1)?

8 Answers

The best thing exists is: Insert in O(1) Delete in O(logn) Max/Min in O(1)

But to do that the insert function must create a link chain and you will also need an extra thread. The good news is that this link chain function also works in O(1) so it will not change the O(1) of insert.

Delete function doesnt break the link chain.

If the target of your delete is the max or min then the delete will be executed in O(1)

The data structure is a mix of an avl tree and a linked list.

The nature of a true delete is such that you cannot make it work in O(1). Hash tables which work with O(1) delete dont have the cabability to hold all the inputs.

Related