(25 points) Write PriorityQueueClass implemented by maxHeapClass and test it. You can assume that items stored in the priority queue are integer numbers.
Added by Joan R.
Close
Step 1
The maxHeapClass should have the following methods: - `__init__(self)`: Initializes an empty max heap. - `insert(self, item)`: Inserts an item into the max heap. - `delete(self)`: Deletes the maximum item from the max heap and returns it. - `is_empty(self)`: Show more…
Show all steps
Your feedback will help us improve your experience
Florencia Cuzmar and 57 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Suppose you have a deque $D$ containing the numbers $(1,2,3,4,5,6,7,8),$ in this order. Suppose further that you have an initially empty queue $Q .$ Give a code fragment that uses only $D$ and $Q(\text { and no other variables) and results in } D$ storing the elements in the order (1,2,3,5,4,6,7,8).
Implement a method with signature concatenate(LinkedQueue $<\mathrm{E}>\mathrm{Q} 2$ ) for the LinkedQueue $<\mathrm{E}>$ class that takes all elements of $\mathrm{Q} 2$ and appends them to the end of the original queue. The operation should run in $O(1)$ time and should result in $Q 2$ being an empty queue.
In Java: Write a method called maxToTop that takes a stack of integers as a parameter and moves the largest value in the stack to the top of the stack, leaving all other values in their original order. You may assume that the stack does not contain any duplicates. For example, if a stack s stores [27, 5, 42, -11, 0, 19], the call of maxToTop(s) should change it to store [27, 5, -11, 0, 19, 42]. If the stack is empty, your method should not change it. Use one queue as auxiliary storage.
Supreeta N.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD