Naïve solutions
Unsorted array
Idea: | put new items at the end of the array; when deleting, fill the gap by the last item |
Advantages: | very simple; insert in $O(1)$ |
Disadvantages: | extract-min takes linear time (we have to search the whole array for a new minimum) |
Sorted array
Idea: | keep all the items in a sorted order |
Advantages: | still simple; extract-min in $O(1)$ |
Disadvantages: | insert in $O(n)$ |