complexityheapssorting
A heap is for repeated min or max access
Anonymous
A binary heap gives access to its root in O(1); adding an item or removing the root takes O(log n). It doesn't keep the whole collection sorted, so use one when repeated access to the smallest or largest item matters more than ordered traversal.
0