Some algorithms implementation.