
Christian H. answered 10/04/20
PhD student in theoretical computer science
I propose a randomized algorithm to tackle this problem. We wish to find an element with priority in the bottom 50% of priority values that exist within our array of events. If we were to randomly choose an event from the array, this would imply we will choose a low priority event with probability 1/2. So what we can do is randomly choose an element k times and keep the element after each sample that has the lowest priority.
The probability we do not find a low priority element is equal to the probability that none of our samples are a low priority element. In particular, the probability of this event is equal to (1/2)^k. For a constant value of k, we will have an O(1) algorithm that successfully finds a low priority element with probability equal to 1 - (1/2)^k. For example, choosing k = 10 gives us that we find a low priority element with probability equal to roughly 0.999 using O(1) time.