best amortized option for insert remove element on min heap

自古美人都是妖i 提交于 2020-12-10 17:38:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!