Java codes for Algos