n = 2h + 1 − 1 n + 1 = 2h + 1 log2(n + 1) = log2(2h + 1) log2(n + 1) = h + 1 h = log2(n + 1) - 1 h = O(log(n))
Therefore, the time it takes to do adds and removes in a binary heap is O(log(n)) (logarithmic), where n is the number of nodes in the heap.