Algorithm course (java implentation)