public class TopM extends java.lang.Object
MinPQ
of size
at most M + 1 to identify the M largest transactions
and a Stack
to 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 |
---|---|
static void |
main(java.lang.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.
|