Algorithms and their implementation in C++