Java programs for implementing different algorithms