Editted alg.cpp and alg.h