Implementation of various algorithms in Java and C#