For this lab you write a program that reads integers from stand input and keeps smallest of them. supply the program. I'll also supply HeapMaxPQ and HeapMinPQ, which are implementations of the MinPQ and MaxPQ interfaces. You'll write the rest. What you'll need to do is this: 1. Create a Scanner object to read from standard input (System.in). 2. Read N (the number of smallest items to keep) from standard input. 3. Create a priority queue (either HeapMaxPQ or HeapMinPQ - you'll need to figure out which). 4. read integers from standard input until there are no more to read. 5. Use the priority queue to keep track of the smallest N integers. 6. When you're done reading the data, write out the N smallest integers from largest to smallest, one per line. For example, if you're keeping the 4 smallest integers, and the input data is 3 19 81 9 18 58 40 61 13 74 82 60 64 45 40 47 24 60 47 90 the output should be com am 18 13 9 Recall that the API for MinPQ is: Function constructor insert min del Min size isEmpty Signature HeapMinPQ(int initialSize) void insert(T t) T min() T delMin() int size() boolean isEmpty() constructor Description inserts t into the priority queue returns the current minimum value without removing it returns the current minimum value and removes it returns the number of items in the priority queue returns true if the priority queue is empty, false otherwise The API for MaxPQ is similar, but with Max substituted for Min.
For this lab you write a program that reads integers from stand input and keeps smallest of them. supply the program. I'll also supply HeapMaxPQ and HeapMinPQ, which are implementations of the MinPQ and MaxPQ interfaces. You'll write the rest. What you'll need to do is this: 1. Create a Scanner object to read from standard input (System.in). 2. Read N (the number of smallest items to keep) from standard input. 3. Create a priority queue (either HeapMaxPQ or HeapMinPQ - you'll need to figure out which). 4. read integers from standard input until there are no more to read. 5. Use the priority queue to keep track of the smallest N integers. 6. When you're done reading the data, write out the N smallest integers from largest to smallest, one per line. For example, if you're keeping the 4 smallest integers, and the input data is 3 19 81 9 18 58 40 61 13 74 82 60 64 45 40 47 24 60 47 90 the output should be com am 18 13 9 Recall that the API for MinPQ is: Function constructor insert min del Min size isEmpty Signature HeapMinPQ(int initialSize) void insert(T t) T min() T delMin() int size() boolean isEmpty() constructor Description inserts t into the priority queue returns the current minimum value without removing it returns the current minimum value and removes it returns the number of items in the priority queue returns true if the priority queue is empty, false otherwise The API for MaxPQ is similar, but with Max substituted for Min.
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
Related questions
Question
I need help with the main function, please. I can't provide command-line arguments, I need an alternative
I have all classes I need I just need the main function
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
Knowledge Booster
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
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education