It seems to me that Binary Search Tree can do everything a Binary heap can do, plus additional things.
| | Heap | Bal. BST |
---------------------------------------------
| Lookup min element | O(1) | O(1) |
---------------------------------------------
| Add an element | O(logn) | O(logn) |
---------------------------------------------
| Find and Remove | O(n) | O(logn) |
| an element | | |
---------------------------------------------
As a consequence of find and remove properties, it is possible to mutate an element, and we can pretty much ensure the order is still maintained after mutation in O(logn)
time
The advantages I see with Binary Heap are
i) Simpler to implement ii) Memory allocated is contiguous (and thus faster access)
(i) is non-issue as I'll be rarely implementing any of them from scratch. If we are mutating the elements a lot, then (ii) is not a significant advantage.
It seems to me that balanced binary tree can do everything that a binary heap can do, then why is it not used ubiquitously? (Like Doubly Linked Lists are used ubiquitously over Singly LinkedLists)