Asymptotic time complexity of inserting n elements to a binary heap already containing n elements

前端 未结 3 643
予麋鹿
予麋鹿 2021-01-05 06:58

Suppose we have a binary heap of n elements and wish to insert n more elements(not necessarily one after other). What would be the total time required for this?

I th

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-05 07:37

    its not theeta(nlogn)... its order(nlogn) since some of the insertions can take less then exact logn time... therefore for n insertions it will take time <=nlogn

    => time complexity=O(nlogn)

提交回复
热议问题