Algorithm implementations in Java