classical algorithms implementation