public class TopM extends Object
TopMclass provides a client that reads a sequence of transactions from standard input and prints the m largest ones to standard output. This implementation uses a
MinPQof size at most m + 1 to identify the M largest transactions and a
Stackto output them in the proper order.
For additional documentation, see Section 2.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
|Modifier and Type||Method and Description|
Reads a sequence of transactions from standard input; takes a command-line integer m; prints to standard output the m largest transactions in descending order.
public static void main(String args)
args- the command-line arguments