C++/Is heap an implicit data structure to implement priority queue?
Expert: vijayan - 1/20/2012
QuestionMy question might seem childish but I really don't understand this question as I am just a newbie to data structures course. I do know how max and min hip work, but I am not sure that whether heap is implicit data structure to implement priority queue.
Kindly clear my confusion.
Thanks...
Alan
AnswerI too don't really understand what the term 'an implicit data structure' means.
Perhaps, the question should have been: 'Is some kind of heap the only data structure that can be used to implement a priorority queue'?
The answer is no.
"It is a common misconception that a priority queue is a heap. A priority queue is an abstract concept like "a list" or "a map"; just as a list can be implemented with a linked list or an array, a priority queue can be implemented with a heap or a variety of other methods.
...
While relying on a heap is a common way to implement priority queues, for integer data faster implementations exist (this can even apply to datatypes that have finite range, such as floats)"
- Wiki
http://en.wikipedia.org/wiki/Priority_queue