Algorithms implementations in Java