Implementation of D-Algorithm (Roth)