On CLRS\'s textbook \"Introduction to Algorithm\", there\'s such paragraph on pg. 258.
We can delete an element in O(1) time if the lists are doubly linked. (Note th
Coding point of view:
one can use unordered_map in c++ to implement this.
unordered_mapmp;
Where node* is a pointer to a structure storing the key, left and right pointers!
How to use:
If you have a value v and you want to delete that node just do:
Access that nodes value like mp[v].
Now just make its left pointer point to the node on its right.
And voila, you are done.
(Just to remind, in C++ unordered_map takes an average O(1) to access a specific value stored.)