Some basic algorithms implemented in java