Get an introduction to priority queues.
- [Instructor] Now we are ready to talk…about the priority queue container adapter.…Recall that a priority queue is a container…that keeps its elements ordered naturally.…This is because it's implemented as a heap,…which is a data structure that has the behavior…of a binary tree, which keeps its elements ordered;…and the way to use a priority queue is by pushing elements…in any order, but you will only be able…to pop the maximum of those elements.…
And so everything you pop back will be in descending order.…We will do this demo as an adaptation…the same way we've been doing it before.…Here we'll take the demo of the queue,…and we will turn it into the priority queue behavior.…First, I will change the initial comment to priority queue;…and, interestingly enough, the header file…where the prior queue is defined,…is the same queue header file.…
So the first adaption will be in line number 10…where we change the queue by a priority queue.…The next modification is a bit odd,…and it will have to happen on line number 23.…
- Why the STL is important
- Containers and iterators
- Vectors and lists
- Stacks and dequeues
- Associative containers
Skill Level Advanced
1. The Standard Template Library
2. Vectors and Lists
3. Stacks, Queues, and Deques
4. Associative Containers
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.