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

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:00
Which virus-infecting components are email messages prone to carry? one of the problems associated with the use of email communication is that email messages are prone to carry virus-infecting .
Answers: 3
question
Computers and Technology, 22.06.2019 10:30
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
Experimental data that is expressed using numbers is said to be
Answers: 1
question
Computers and Technology, 23.06.2019 10:20
Suppose there is a relation r(a, b, c) with a b+-tree index with search keys (a, b).1. what is the worst-case cost of finding records satisfying 10 < a < 50 using this index, in terms of the number of records n1, retrieved and the height h of the tree? 2. what is the worst-case cost of finding records satisfying 10 < a < 50 and 5 < b < 10 using this index, in terms of the number of records n2 that satisfy this selection, as well as n1 and h defined above? 3. under what conditions on n1 and n2, would the index be an efficient way of finding records satisfying the condition from part (2)?
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