Complete the code to create a new empty priority queue using Rust's standard library.
let mut pq = std::collections::BinaryHeap::[1]();The new function creates an empty BinaryHeap, which is Rust's priority queue.
Complete the code to add an element 10 to the priority queue.
pq.[1](10);
The push method adds an element to the priority queue.
Fix the error in the code to remove the highest priority element from the priority queue.
let max = pq.[1]().unwrap();The pop method removes and returns the highest priority element from the queue.
Fill both blanks to check if the priority queue is empty and print a message.
if pq.[1]() [2] true { println!("Priority queue is empty"); }
The is_empty method checks if the queue has no elements, and == compares the result to true.
Fill all three blanks to create a priority queue from a vector, pop the top element, and peek at the next top element.
let mut pq = std::collections::BinaryHeap::from([1]); let top = pq.[2]().unwrap(); let next = pq.[3]().unwrap();
We create a BinaryHeap from a vector using from, then remove the top element with pop, and finally look at the next top element with peek.
