Looking For Anything Specific?

Free Demo

📚 Book a Free Online Demo Class Now!

Learn with clarity, personal mentorship & expert guidance.

🚀 Book Now

Algorithm


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:


1. Take water in a pan.



2. Boil the water.



3. Add tea leaves.



4. Add milk and sugar.



5. Boil for a few minutes.



6. 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:


1. Start.



2. Enter the first number A.



3. Enter the second number B.



4. Calculate SUM = A + B.



5. Display SUM.



6. Stop.




6. Example: Find the Greater of Two Numbers


Algorithm:


1. Start.



2. Enter two numbers A and B.



3. Compare A and B.



4. If A > B, display A as the greater number.



5. Otherwise, display B as the greater number.



6. 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.

Post a Comment

0 Comments