The Priority. Queue ADT As an ADT, a priority queus P supports the following functions: • • • • isPQueueEmpty(): returns true if pqueue is empty otherwise false size(): Return the number of elements in P. smpty(): Return true if P is empty and false otherwise. insert(e): Insert a new element e into, P. ● min): Return a reference to an element of P with the smallest associated kex value (but do not remove it); an error condition occurs if the priority queue is empty. • removeMin(): Remove from P the element referenced by min(); an error condition occurs if the priority queue is empty. Example: The following table shows a series of operations and their effects on an initially empty priority queue P. Each element consists of an integer, which we assume to be sorted according to the natural ordering of the integers. Note that each call to min returns a reference to an entry in the queue, not the actual value. Although the "Priority. Queue" column shows the items in sorted order, the priority queus need not store elements in this order.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
The Priority. Queue ADT
As an ADT, a priority queue P supports the following functions:
•
isPQueueEmpty(): returns true if pqueue is empty otherwise false
size(): Return the number of elements in P.
empty(): Return true if P is empty and false otherwise.
Example: The following table shows a series of operations and their effects on an initially
empty priority queue P. Each element consists of an integer. which we assume to be sorted
according to the natural ordering of the integers. Note that
insert(e): Insert a new element e into P.
min(): Return a reference to an element of P with the smallest associated kex value
(but do not remove it); an error condition occurs if the priority queue is empty.
removeMin): Remove from P the element referenced by min(); an error condition
occurs if the priority queue is empty.
each call to min returns a reference to an entry in the queue, not the actual value. Although the
"Priority Queue" column shows the items in sorted order, the priority queue need not store.
elements in this order.
Operation Return
insert(5)
insert(9)
insert(2)
insert(7)
min()
size()
min()
[2]
removeMin [2]
3
[5]
removeMin [5]
removeMin [7]
removeMin [9]
}
Priority Queue
{5}
{5,9}
{2,5,9}
{2,5,7,9}
{2,5,7,9}
{5,7,9}
{5,7,9}
{5,7,9}
{7,9}
{9}
{}
empty()
true
removeMin invalid operation {}
You may use following interface to implement PriorityQueus
public interface PriorityQueue{
public int peek():
public void insert(int item);
public int deletMin();
public int size();
Transcribed Image Text:The Priority. Queue ADT As an ADT, a priority queue P supports the following functions: • isPQueueEmpty(): returns true if pqueue is empty otherwise false size(): Return the number of elements in P. empty(): Return true if P is empty and false otherwise. Example: The following table shows a series of operations and their effects on an initially empty priority queue P. Each element consists of an integer. which we assume to be sorted according to the natural ordering of the integers. Note that insert(e): Insert a new element e into P. min(): Return a reference to an element of P with the smallest associated kex value (but do not remove it); an error condition occurs if the priority queue is empty. removeMin): Remove from P the element referenced by min(); an error condition occurs if the priority queue is empty. each call to min returns a reference to an entry in the queue, not the actual value. Although the "Priority Queue" column shows the items in sorted order, the priority queue need not store. elements in this order. Operation Return insert(5) insert(9) insert(2) insert(7) min() size() min() [2] removeMin [2] 3 [5] removeMin [5] removeMin [7] removeMin [9] } Priority Queue {5} {5,9} {2,5,9} {2,5,7,9} {2,5,7,9} {5,7,9} {5,7,9} {5,7,9} {7,9} {9} {} empty() true removeMin invalid operation {} You may use following interface to implement PriorityQueus public interface PriorityQueue{ public int peek(): public void insert(int item); public int deletMin(); public int size();
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education