priority_queue big o notation with vector and deque

Started by
9 comments, last by lride 11 years, 5 months ago
In more detail, nodes in a heap can be assigned indices that are small consecutive integers, which makes it possible to use a vector or a deque for storage. Node 0 is the root, nodes 2*i+1 and 2*i+2 are the children of node i, and node (i-1)/2 is its parent. The resulting implementation of a heap is quite efficient, and that's probably how priority_queue is implemented by your library (although there are other possibilities).

You can read more about it here.
Advertisement

In more detail, nodes in a heap can be assigned indices that are small consecutive integers, which makes it possible to use a vector or a deque for storage. Node 0 is the root, nodes 2*i+1 and 2*i+2 are the children of node i, and node (i-1)/2 is its parent. The resulting implementation of a heap is quite efficient, and that's probably how priority_queue is implemented by your library (although there are other possibilities).

You can read more about it here.

Thank you. That cleared up my question.
An invisible text.

This topic is closed to new replies.

Advertisement