Java Algorithms I have been working on