An algorithm is the step-by-step method used to solve a problem or perform a task on a computer. Before a computer starts working, it needs clear instructions. These instructions are called an algorithm.
In simple words, an algorithm is like a recipe. Just as we follow steps to cook food, a computer follows steps to complete a task.