I have a sorted list of integers, and I wish to insert into this list any element, in constant time. I'm allowed to do some pre-processing, as long as it will let me run this operation in constant time (i.e., no matter how many times I repeat this operation after the pre-processing, it should run in constant time).
How can this be done?
Edit : I can think of a couple of more constraints to make it a bit less ambiguous, and a bit more challenging to solve -
- list needs to be maintained in sorted order post-insertion(s)
- Or, list needs to somehow support max/min operations in constant time post insertion(s).