algorithms from coursework (java)