Is the worst-case of this algorithm equal to $\Theta(n)$ or $\Theta(n\lg n)$?
You need a data structure that supports the following three operations efficiently:


insert an element into the set
delete an element from the set
find the largest element in the set


There are multiple such data structures.  One reasonable choice is a balanced binary search tree, where all three operations can be implemented in $O(\log n)$ time.