Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions 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.
expand button
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
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education