I am desperately looking for a data structure that allows for a large number of attachments, almost as many deletions (probably of the same order), and a very quick search for the highest (or lowest) can live with) cost. Deletion will always affect only the highest (or, again, the lowest) value. The problem is that the values ββhave to be sorted, and at any moment I could insert an element going at any point between the other two. The only value that I want to read (and delete) quickly, at any time, is the maximum (or, again, the minimum).
Is there anything you recommend?
Please provide an algorithmic complexity analysis for your suggested answers.
source share