Entry
What is the use of a heap data structure?
May 14th, 2000 05:51
unknown unknown, Courageous
A heap priority queue has the property such that the elements
can be inserted and pulled out in a user-defined order in O(log N)
time. So, for example:
heap.push(7)
heap.push(3)
heap.push(9)
heap.push(2)
would be popped()
as 2,3,7,9
Obviously such a data structure is only needed when appending
onto the end all the time isn't possible (otherwise you'd
just use something like a fifo, both pushing and popping in
O(1)).