Implementation for all algorithms in Java