Miscallaneous Java Algorithms