问题
I ran into an interview question recently. no additional info is given into question (maybe default implementation should be used...)
n arbitrary sequences of insert and remove operations on empty min heap (location for delete element is known) has amortized cost of:
A) insert O(log n), remove O(log n)
B) insert O(log n), remove O(1)
The option (B) is correct.
We know option (A) is also can be correct but why (B) is a better option.
来源:https://stackoverflow.com/questions/65203302/best-amortized-option-for-insert-remove-element-on-min-heap