1. What is an Algorithm?
An algorithm is a step-by-step set of instructions used to solve a problem or complete a task.
Example: Algorithm to make tea:
- Take water in a pan.
- Boil the water.
- Add tea leaves.
- Add milk and sugar.
- Boil for a few minutes.
- Strain and serve.
2. Characteristics of an Algorithm
A good algorithm should have:
- Input: It may take one or more inputs.
- Output: It should produce a result.
- Definiteness: Every step should be clear and unambiguous.
- Finiteness: It must end after a finite number of steps.
- Effectiveness: Each step should be simple and possible to perform.
3. Why Do We Use Algorithms?
Algorithms help us to:
- Solve problems systematically.
- Understand the solution before programming.
- Find and correct mistakes easily.
- Convert a problem into a computer program.
- Save time and effort.
4. Algorithm vs. Program
5. Example: Add Two Numbers
Problem: Find the sum of two numbers.
Algorithm:
- Start.
- Enter the first number A.
- Enter the second number B.
- Calculate SUM = A + B.
- Display SUM.
- Stop.
6. Example: Find the Greater of Two Numbers
Algorithm:
- Start.
- Enter two numbers A and B.
- Compare A and B.
- If A > B, display A as the greater number.
- Otherwise, display B as the greater number.
- Stop.
7. Steps for Writing an Algorithm
Understand the problem → Identify inputs → Decide the required process → Identify output → Write clear steps → Check the solution
Quick Revision
Algorithm = Step-by-step instructions to solve a problem.
Remember:
- Input → Processing → Output
- This is the basic concept you should learn before moving to Flowcharts.


0 Comments