basic algorithm test codes