Complete the sentence to define a priority queue.
A priority queue is a data structure where elements are removed based on their [1] rather than their insertion order.A priority queue removes elements based on their priority, not the order they were added.
Complete the sentence to describe the typical operation of a priority queue.
In a priority queue, the element with the [1] priority is removed first.
The element with the highest priority is removed first in a priority queue.
Fix the error in the statement about priority queues.
A priority queue always removes elements in the order they were added, which is [1] behavior.
This statement is incorrect because priority queues remove elements based on priority, not insertion order.
Fill both blanks to complete the description of priority queue operations.
To add an element, use the [1] operation; to remove the highest priority element, use the [2] operation.
In priority queues, enqueue adds elements, and dequeue removes the highest priority element.
Fill all three blanks to complete the priority queue comprehension.
priority_queue = [(item, [1]) for item in items] priority_queue.sort(key=lambda x: x[[2]], reverse=[3])
The list holds tuples of (item, priority). Sorting uses index 1 (priority) and True for descending order to get highest priority first.