subject

Problem 2 - K-Best Values - 30 points Find the k-best (i. e. largest) values in a set of data. Assume you are given a sequence of values, one value at a time. We do not know how many elements there are in this sequence. In fact, there could be infinitely many. Implement the class KBestCounter> implements KBest that keeps track of the k-largest elements seen so far in a sequence of data. The class should have two methods: public void count(T x) - process the next element in the set of data. This operation must run in at worst O(log k) time. public List kbest() - return a sorted (smallest to largest) list of the k-largest elements. This must run in at worst O(k log k) time. The method must not clobber the state of your class. This means that if you run this method twice in a row, it should return the same values. Your KBestCounter. java class must implement the provided interface KBest. java. Use a priority queue to implement this functionality. We suggest using the built-in java. util. PriorityQueue. As always, feel free to implement your own tester file to ensure proper functionality.

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:20, kaiyerecampbell95
Pp 4.1 design and implement a class called sphere that contains instance data that represents the sphere’s diameter. define the sphere constructor to accept and initialize the diameter and include getter and setter methods for the diameter. include methods that calculate and return the volume and surface area of the sphere (see pp 3.5 for the formulas). include a tostring method that returns a one-line description of the sphere. create a driver class called multisphere, whose main method instantiates and updates several sphere objects.
Answers: 1
image
Computers and Technology, 23.06.2019 09:50, tatumleigh04
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
image
Computers and Technology, 23.06.2019 17:00, Need1ng
The more powerful, 60 volt cables and the main power shut-off on an hev are both colored orange.
Answers: 1
image
Computers and Technology, 24.06.2019 00:40, dheydar3506
What is the error in the following pseudocode? module main() call raisetopower(2, 1.5) end module module raisetopower(real value, integer power) declare real result set result = value^power display result end module
Answers: 1
You know the right answer?
Problem 2 - K-Best Values - 30 points Find the k-best (i. e. largest) values in a set of data. Assum...

Questions in other subjects:

Konu
Mathematics, 08.10.2019 09:00
Konu
Mathematics, 08.10.2019 09:00