typical algorithms implementation