Implementation of basic algorithms in Java