Implement a priority queue using java.util.Stack as the base data type. Your code must not reference java.util.PriorityQueue! You may need several Java classes for this: one to define Entry, one for the priority queue, and one for the main program. It's acceptable to use inner classes if you'd rather have everything contained in one .java file. Feel free to reuse code from the sample files, on-line sources, this lab, and/or the textbook. Please cite any code found on-line. Your priority queue must implement the following methods: insert (Entry E) removeMin () Where Entry is: int k; String v; The core data storage should be: Stack s; Hint: you may need more than one stack to fully implement the queue! The following test cases should be hard-coded into your program: Input (in order) (3, "test") (4,"every") (5, "edge") (10,"smoked") (5, "quality") (12,"beef") (1, "good") - inserts a new node E in the priority queue - returns the entry with the lowest key value (9,"or") (3, "to") (5, "be") (10,"not") Output (in order) (3, "test") (4,"every") (5, "edge") (1, "good") (5, "quality") (10,"smoked") (12,"beef") (3, "to") (5, "be") (9,"or") (10,"not") I am not picky about output formatting, but the data must come from the priority queue. The program must work for any correct sequence of entries, not just the test cases.

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

For Java.

Implement a priority queue using java.util.Stack as the base data type.
Your code must not reference java.util. PriorityQueue!
You may need several Java classes for this: one to define Entry, one for the priority
queue, and one for the main program. It's acceptable to use inner classes if you'd rather
have everything contained in one .java file.
Feel free to reuse code from the sample files, on-line sources, this lab, and/or the
textbook. Please cite any code found on-line.
Your priority queue must implement the following methods:
insert (Entry E)
removeMin ()
Where Entry is: int k; String v;
The core data storage should be: Stack<Entry> s;
Hint: you may need more than one stack to fully implement the queue!
The following test cases should be hard-coded into your program:
Input (in order)
(3,"test")
(4,"every")
(5, "edge")
(10,"smoked")
(5, "quality")
(12,"beef")
(1, "good")
(9,"or")
(3, "to")
(5, "be")
(10,"not")
- inserts a new node E in the priority queue
- returns the entry with the lowest key value
Output (in order)
(3, "test")
(4,"every")
(5, "edge")
(1, "good")
(5, "quality")
(10,"smoked")
(12,"beef")
(3, "to")
(5, "be")
(9,"or")
(10,"not")
I am not picky about output formatting, but the data must come from the priority
queue.
The program must work for any correct sequence of entries, not just the test cases.
Transcribed Image Text:Implement a priority queue using java.util.Stack as the base data type. Your code must not reference java.util. PriorityQueue! You may need several Java classes for this: one to define Entry, one for the priority queue, and one for the main program. It's acceptable to use inner classes if you'd rather have everything contained in one .java file. Feel free to reuse code from the sample files, on-line sources, this lab, and/or the textbook. Please cite any code found on-line. Your priority queue must implement the following methods: insert (Entry E) removeMin () Where Entry is: int k; String v; The core data storage should be: Stack<Entry> s; Hint: you may need more than one stack to fully implement the queue! The following test cases should be hard-coded into your program: Input (in order) (3,"test") (4,"every") (5, "edge") (10,"smoked") (5, "quality") (12,"beef") (1, "good") (9,"or") (3, "to") (5, "be") (10,"not") - inserts a new node E in the priority queue - returns the entry with the lowest key value Output (in order) (3, "test") (4,"every") (5, "edge") (1, "good") (5, "quality") (10,"smoked") (12,"beef") (3, "to") (5, "be") (9,"or") (10,"not") I am not picky about output formatting, but the data must come from the priority queue. The program must work for any correct sequence of entries, not just the test cases.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Threads in linked list
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.
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