Reputation: 1
Is there a algorithm to perform insertions into a heap with atmost one swap (O(log n) comparisons are allowed)
Upvotes: 0
Views: 90
Reputation: 64904
No.
Consider this 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.
Upvotes: 1