Algorithmic implementation of various algorithms in c++