Insertions into a max heap with atmost one swap

101 Views Asked by At

Is there a algorithm to perform insertions into a heap with atmost one swap (O(log n) comparisons are allowed)

1

There are 1 best solutions below

0
On

No.

Consider this heap:

max heap

Suppose you add 200. Obviously it will have to become the new root.

So where does 100 go? It can't become a child of 3, and that's what it would have to do if you only have one swap.