1. What is an Algorithm?
An algorithm is fundamentally a set of well-defined steps or instructions for completing a task or solving a specific problem. Think of it as a recipe for your computer.
Key Characteristics
- Input: An algorithm must accept zero or more inputs (data to process).
- Output: It must produce at least one output (the result).
- Definiteness: Each step must be clear and unambiguous.
- Finiteness: It must terminate after a finite number of steps.
- Effectiveness: Every instruction must be basic enough to be carried out.
Examples in Daily Life
- Making Tea: (1) Boil water, (2) Add tea bag, (3) Steep, (4) Add milk/sugar (optional).
- Finding a Contact: (1) Open phonebook, (2) Look for the first letter, (3) Scan alphabetically.
In programming, algorithms are used to sort lists, search databases, calculate routes (like Google Maps), and much more.