What data structure is required for storing a set of integers such that deletion of the smallest element and insertion of an element not already present in the set can each be done in time?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Searching a binary tree of size N, requires only log N operations. While a heap is pretty much just that, a non-sorted bunch of numbers. Example: searching for the smallest number in a tree of 8 numbers, only require you to do 3 operations. First (1) you choose between which branch of 4 numbers each you want to go along. Then (2) you choose which branch with 2 numbers each you want to go along. For the third and last operation you choose which of the branches with 1 number each. When you are on a branch with only 1 number on it, you are done.