An algorithm is simply a clear set of step-by-step instructions for completing a task or solving a problem. Algorithms exist outside of computers too โ a recipe for baking cookies or directions for tying your shoes are both examples of everyday algorithms.
In programming, algorithms need to be precise and unambiguous, since a computer will follow the instructions exactly as written, without guessing what you meant. A good algorithm also considers different situations it might encounter, using logic to decide what to do next based on conditions, such as 'if this happens, then do that.'
Computer scientists often compare algorithms by how efficient they are โ how much time or memory they need to solve a problem, especially as the size of the problem grows. Writing an efficient algorithm can make the difference between a program that runs instantly and one that takes far too long to finish.