Recent - Posts

Algorithm and Flowchart For students From Basic to Advanced (Level - 1)

Algorithms and Flowcharts

Algorithm and Flowchart
Algorithm & Flowchart

Introduction

        In the domain of computers, algorithms and flowcharts are similar to planning tools.
We have to specify exactly what has to be done and in what order before a computer can solve a        problem.

  • The objectives of this blog post is to understand:
  • What are flowcharts and algorithms?
  • The reasons behind their significance
  • How algorithms are written
  • How to create and comprehend flowcharts
  • Typical errors to prevent
  • Practice questions and answer.

What is an Algorithm?

Algorithm
Algorithm

An algorithm is a methodical approach to problem solving.
  • It is comparable to a cooking recipe.
  • You will receive the right outcome if you correctly follow the instructions.
For instance, in actual life:
  • How to clean your teeth.
  • How to prepare a sandwich.
  • How to solve a maths issue.

What is a Flowchart?

An algorithm's graphic, or diagram, is called a flowchart. Pictorial representation of algorithm is a flowchart. 
  • It is also an important programming tool.
  • It illustrates steps using boxes, arrows, and symbols.
  • It makes it simple to observe how the task proceeds from beginning to conclusion.

Importance of Algorithm & Flowchart

  • Before you begin building a computer program, they assist you with planning.
  • They help you think clearly and systematically.
  • They lessen software errors.
  • In real life, they are also helpful for organising work, managing your day, and solving riddles.  

Level - 1: Beginner        

Concept of Algorithm

Definition:

                An algorithm is a set of precise instructions in finite number of steps that you must follow in order to complete a task or resolve an issue.

Features of Good Algorithm:

A good algorithm must have:
  • Establish definite beginning and finishing points.
  • Put the steps in the right sequence.
  • Every stage must to be easy to understand and straightforward.
  • You should always receive the correct answer if you follow the instructions.
  • It shouldn't take an endless amount of time to complete.

Sample Algorithms (Basic Examples from Everyday Life)

Instead of using any computer language, its better use our natural language.        

Algorithm for Brushing Your Teeth:

Step 1: Proceed to the washbasin.
Step 2: Grab your toothbrush.
Step 3: Apply toothpaste to the brush.
Step 4: Turn on tap and wet the brush.
Step 5: Give your teeth a good brushing.
Step 6: Use water to rinse your mouth.
Step 7: Clean the toothbrush.
Step 8: Switch off the tap.
Step 9: Don't move the toothbrush.
Step 10: Use a cloth to clean your mouth

  

Algorithm for making a Cup of Tea:

Step 1: Grab a pan or kettle.
Step 2: Fill the pan with water.
Step 3: Turn on the electric or gas cooker.
Step 4: Put the pan on the hob.
Step 5: Hold off till water begins to boil.
Step 6: To the boiling water, add tea leaves.
Step 7: If necessary, add sugar.
Step 8: If you prefer milk tea, add milk.
Step 9: Boil for two to three minutes.
Step 10: Switch off the stove.
Step 11: Pour the tea through a strainer into a cup.
Step 12: Serve the tea or sip it.

Algorithm for getting Ready for School:

Step 1: Get up.
Step 2: Give your teeth a brushing.
Step 3: Have a bath.
Step 4: Put on your school uniform.
Step 5: Make your hair.
Step 6: Have your breakfast.
Step 7: Put all necessary items in backpack.
Step 8: Grab water bottle and your tiffin.
Step 9: Check the time.
Step 10: Get to school promptly.


        
Algorithm for Adding Two Numbers:

Step 1: Let's read the first number A.
Step 2: Let's read the second number B.
Step 3: Add A and B.
Step 4: Write or display the outcome (A + B)

        Algorithm for Making a Sandwich:

Step 1: Take two bread pieces.
Step 2: On one side of each slice, put butter.
Step 3: Put filler or veggies on one slice.
Step 4: Place second one, over the filling.
Step 5: Cut the sandwich.
Step 6: Eat the sandwich or serve it.    

Concepts of Flowchart

Definition:

flowchart is:
    a graphic or pictorial  illustration of an algorithm in steps using boxes and arrows.

Basic Flowchart Symbols:

Basic Flowchart Symbols
Flowchart Symbols

Example 1: Flowchart for adding two numbers

Question: Read two Numbers and Display their Sum.
 
Algorithm:                                                                                                   
Step 1: Start.

Step 2: Read the first number (A).

Step 3: Read the second number (B).

Step 4: Calculate Sum = A + B.

Step 5: Display Sum.

Step 6: End.

Example no 2: Flowchart to make a Sandwich:

flowchart to make a sandwich
Question: Draw a flowchart showing steps to make a Sandwich.

Algorithm:
                                                                 
Step 1: Start.

Step 2: Take two slices of bread.

Step 3: Spread butter on one side of each slice.

Step 4: Put filling (vegetables, cheese, etc.) on one slice.

Step 5: Place the second slice on top.

Step 6: Cut the sandwich (optional).

Step 7: Serve the sandwich.

Step 8: End.

Example no 3: Flowchart of brushing of teeth.

Question: Draw a flowchart showing steps how to brush teeth.               
Algorithm:
                                                                   
Step 1: Start.

Step 2: Take toothbrush.

Step 3: Put toothpaste on toothbrush.

Step 4: Wet the brush.

Step 5: Brush teeth for 2–3 minutes.

Step 6: Rinse mouth.

Step 7: Wash toothbrush.

Step 8: Keep brush back.

Step 9: End.

Practice Questions:
  1. Write an algorithm for tying your shoelaces.
  2. Write an algorithm for making a glass of lemonade.
  3. Write an algorithm to add three numbers.
  4. Write an algorithm for preparing your school bag for the next day.
  5. Write an algorithm for washing your hands properly.
  6. Draw a flowchart to add three numbers and display the result.
  7. Draw a flowchart for deciding whether to carry an umbrella (if it is raining, carry an umbrella; otherwise, don’t).
  8. Draw a flowchart for buying a movie ticket (very simple: check if you have enough money).
  9. Write an algorithm and draw/describe a flowchart to find the total cost of buying 5 identical pencils when the price of one pencil is given.
  10. Write an algorithm for eating in a restaurant (from entering to paying the bill).
Note: First, Give it a try yourself, and do come back here to check the answers.

Recommended  Solutions :

Q1. Algorithm for Tying Your Shoelaces

Step 1: Sit down and place one foot on your knee or bend down.

Step 2: Take one lace in your left hand and the other lace in your right hand.

Step 3: Cross the laces to form an “X”.

Step 4: Pass one lace under the other and pull both ends to tighten.

Step 5: Make a loop (bunny ear) with the left lace.

Step 6: Wrap the right lace around the loop.

Step 7: Pull the right lace through the hole to form a second loop.

Step 8: Pull both loops to tighten the knot.


Q2. Algorithm for Making a Glass of Lemonade

Step 1: Take a clean glass.

Step 2: Add some sugar to the glass.

Step 4: Add a pinch of salt (optional).

Step 5: Pour water into the glass.

Step 6: Stir the mixture with a spoon until sugar dissolves.

Step 7: Add ice cubes (optional).

Step 8: Serve or drink the lemonade.


Q3. Algorithm to Add Three Numbers
                
Step 1: Start.

Step 2: Take three numbers and call them A, B and C.

Step 3: Calculate Sum = A + B + C.

Step 4: Display Sum.

Step 5: End.


Q4. Algorithm for Preparing Your School Bag

Step 1: Check the timetable for the next day.

Step 2: For each subject in the timetable:

Step 3: Put the correct textbook in the bag.

Step 4: Put the correct notebook in the bag.

Step 5: Add your pencil box.

Step 6: Add your homework notebooks.

Step 7: Add your tiffin box and water bottle (if you pack them now).

Step 8: Keep the bag near the door or in its usual place.


Q5. Algorithm for Washing Hands Properly

Step 1: Turn on the tap.

Step 2: Wet your hands with clean water.

Step 3: Apply soap on your hands.

Step 4: Rub your hands together (front and back, between fingers, under nails) for at least 20                                seconds.

Step 5: Rinse your hands under running water.

Step 6: Turn off the tap.

Step 7: Dry your hands with a clean towel or tissue.


Q6. Flowchart to Add Three Numbers 

Problem: Read three numbers A, B, C and display their sum                                                                                             
Algorithm:

Step 1: Start.

Step 2: Enter A, B, C.

Step 3: Calculate Sum = A + B + C.

Step 4: Display Sum.                                

Step 5: End.                                    Flowchart:
      
 
Q7. Flowchart for Deciding Whether to Carry an Umbrella.

Problem: If it is raining, carry an umbrella; otherwise, do not carry it                                                                
Algorithm:

Step 1: Start.

Step 2: Check: Is it raining?

 Step 3: If yes, carry an umbrella.

Step 4: If no, do not carry an umbrella.

Step 5: End.                                          Flowchart:
                                                                       

Hints for Remaining Questions (Q8 – Q10)
  • Q8 (Buying a movie ticket):
Include a decision: “Do I have enough money?” If Yes → “Buy ticket”; If No → “Do not buy ticket / Save money”.
  • Q9 (Total cost of 5 pencils):
Input: price of one pencil (P). Process: Total = 5 × P. Output: Total.
  • Q10 (Eating in a restaurant):
Steps: Enter → Find seat → Read menu → Order food → Eat food → Ask for bill → Pay bill → Leave.

Comments

Anonymous said…
Good job.. babu