algorithms code implement