An algorithm is a procedure or formula for solving a problem, based on conducting a sequence of specified actions. A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem.
An input device is any hardware device that sends data to a computer, allowing you to interact with and control the computer. The picture shows a Logitech trackball mouse, an example of an input device.