Package edu.princeton.cs.algs4
Class TopM
- Object
-
- edu.princeton.cs.algs4.TopM
-
public class TopM extends Object
TheTopM
class provides a client that reads a sequence of transactions from standard input and prints the m largest ones to standard output. This implementation uses aMinPQ
of size at most m + 1 to identify the M largest transactions and aStack
to output them in the proper order.For additional documentation, see Section 2.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
- Author:
- Robert Sedgewick, Kevin Wayne
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
main(String[] args)
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.
-
-
-
Method Detail
-
main
public static void main(String[] args)
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.- Parameters:
args
- the command-line arguments
-
-