Algorithmic practice in java