implement of algorithms