Can we use binary search tree to simulate heap operation?

后端 未结 4 712
失恋的感觉
失恋的感觉 2021-01-04 13:59

I was wondering if we can use a binary search tree to simulate heap operations (insert, find minimum, delete minimum), i.e., use a BST for doing the same job?

Are t

4条回答
  •  伪装坚强ぢ
    2021-01-04 14:19

    Yes, we can, by simply inserting and finding the minimum into the BST. There are few benefits, however, since a lookup will take O(log n) time and other functions receive similar penalties due to the stricter ordering enforced throughout the tree.

提交回复
热议问题