A binary heap is a complete binary tree, so with nodes it has height . Insert and extract operations bubble elements up or down the tree.
Inserting an element adds it to the bottom level and bubbles it up until the heap property holds. In the worst case, it bubbles all the way to the root, taking swaps.
Similarly, extracting the max (or min) removes the root, replaces it with the last element, and bubbles down. This also takes time. Heaps power priority queues with logarithmic operations.