How to write an algorithm – Step 1

Step 1 – Find data, processes and conditions from the problem statement

Writing algorithms is a great way to understand the steps you need to solve a given problem. But as a beginner you will find it difficult to understand how to write algorithms. Therefore you need to understand the steps to write an algorithm and practice them.

First step

The first step you should take after understanding the problem definition is to identify the following items from the problem statement

  1. Data
  2. Process
  3. Conditions

 

These three things are easy to find. Where ever you see some data related information you will need some kind of a variable in your algorithm to save this data. Where ever you find some work being done you will have to put it under the process category. And where ever you will find some decision making statement you will have to put it under conditions. In English we use if-else to represent a condition.

For example read this problem statement below

Rosy was asked by her teacher to write an algorithm to calculate average marks of a student. A student appears for 5 exams and his / her average has to be calculated based on his / her marks in these exams. If the average of the student is below 75 then he / she will be given a D grade, if it falls between 75 and 80 he / she will be given a C grade, if it falls between 80 and 85 ( including 80 ) then he / she will be given a B grade and if the average is above 85 ( excluding 85 ) then he / she will be given an A grade.

Now our task is to find out the data related information, process related information and conditions you find from this given statement. Below we have separated out all this information for your understanding

Data

  1. Marks of 5 subjects are data. You will need variables to remember these marks
  2. The average you will calculate from these marks is also data. You will need a variable to store this also

Process

You need to understand one thing when you try to find out about processes from a problem statement. Some processes are directly visible in the problem statement and some processes are implied. By implied we mean that it’s understood by default. For example in this statement how do you think the marks of the student will get entered into the variable? This won’t happen automatically. Either the marks will be read from some data file or somebody will be entering these marks from the keyboard. Both reading data from a file or entering it from a keyboard becomes a process.

Processes we can find in this statement

  1. Loading marks into variables
  2. Calculating the average of these marks using the average formula and storing it in some variable
  3. Checking in which range the average falls and awarding respective grade

Conditions

In this problem statement there are following conditions

  1. Is the average below 75
  2. Is the average between 75 and 80
  3. Is the average between 80 (including 80) and 85
  4. Is the average above 85 (excluding 85)

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp