Select algorithm through command line options.

This changeset will both add the functionality of command line flags and
the random-algorithm.