classical algorithm describe in The Introduction For Algorithm, written in C++