Asked • 10/04/20

Searching for and removing a low priority item in an array

Suppose you are handed a list of n events, each carrying some priority value represented by a real number in the interval [0,1], where a larger priority corresponds to a more important event. This list is represented by an array that allows you to specify an event index i and instantly grab the event information at position i. Sometimes, an event manager is handed a new event to add to the list. The list can only have n events, so to add an event requires removing an event first.


Suppose we wish to remove events whose priority is low, meaning in the bottom 50% of priority values, and we wish to do this removal in O(1) time. What is an algorithm that can achieve this goal?

1 Expert Answer

By:

Christian H. answered • 10/04/20

Tutor
5 (193)

PhD student in theoretical computer science

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.