java code for the algorithms course