Implemented some algorithms in cpp