0% found this document useful (0 votes)
197 views13 pages

Computer - CH - 3 .Algorithms and Flowcharts

The document discusses algorithms and flowcharts. It defines an algorithm as a step-by-step procedure or formula for solving a problem based on a sequence of specified actions. Algorithms can be simple, like multiplying numbers, or complex, like playing a compressed video file. Good algorithms are precise, unique, finite, take inputs and provide definite outputs, and are generally applicable. The document also outlines steps for developing algorithms, including obtaining a problem description, analyzing the problem, developing a step-wise solution, refining details, and reviewing the algorithm. Flowcharts are then introduced as a visual representation of algorithms showing the sequence of steps and decisions.

Uploaded by

Juthika Singha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
197 views13 pages

Computer - CH - 3 .Algorithms and Flowcharts

The document discusses algorithms and flowcharts. It defines an algorithm as a step-by-step procedure or formula for solving a problem based on a sequence of specified actions. Algorithms can be simple, like multiplying numbers, or complex, like playing a compressed video file. Good algorithms are precise, unique, finite, take inputs and provide definite outputs, and are generally applicable. The document also outlines steps for developing algorithms, including obtaining a problem description, analyzing the problem, developing a step-wise solution, refining details, and reviewing the algorithm. Flowcharts are then introduced as a visual representation of algorithms showing the sequence of steps and decisions.

Uploaded by

Juthika Singha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 13

COMPUTERS - 8

RISEUP Compressed
video ile
ype of o mpresi on
3 Algorithms and Jechnique hotr educes
the sipe of video file
pormats
Flowcharts
Design
Learning Outcomes
Students will be able to:

Experiment
" describe an algorithm.
" tell the characteristics of an algorithm.
analyse a problem.
solution.
apply algorithm to find the best
Implement describe flowchart with its symbols.
" design a flowchart.

Algorithm
Every problem solution starts with a plan. This plan can LEARNING BEYOND
be considered as an algorithm. Therefore. an algorithm
(pronounced AL-go-rith-um) is aprocedure or formula In 1600 BC, Babylonians
for solving a problem, based on asequence of specified developed the earliest
actions (steps). An algorithm can be a simple process, such
Sove as multiplying two numbers, ora complex operation, such known algorithms for
speigie factorisation and finding
prale
hat
as playing a compressed video fle, Search engines use
Square roots.
n proprietary algorithms to display the most relevant results
artiens from their search index for specificqueries.
There are many ways to write an algorithm. An algorithm is generally written in English
language. We use algorithm in our daily life also. The algorithm used in our daily life does
not follow any strict format, as it has to be executed by human beings only. Let us consider
an algorithm for Getting ready for school:
1. Wake up in the morning
2. Brush your teeth and take a bath
3. Wear schooluniform
4. Comb you hair
5. Pack your school bag
6. Have your breakfast
Similarly, writing a recipe for preparing any food item Test Your Skill
is a kind of an algorithm. There can be many ways of
Can you think of some
preparing the same food item, i.e. there can be many algorithms that you use
algorithms to prepare the same food item. in the classroom?

34
However, the recipe that takes less time and less ingredients to prepare the same quality food
item is considered to be a good one. Similarly, an algorithm, which takes less time and requires
less inputs to give the same result is considered as a good algorithm.
Characteristics of a Good Algorithm
Precision
The steps should be precisely stated (defined), i.e. to the point.
Uniqueness
Result of each step is uniquely defined and only depends on the input and the result of the
preceding
rlsus stostep.
Finiteness
8heceThealgorithm must stop after afinite number of instructions or steps. It should not be stuck
proes jn a loop, so that it gives the desired output in the specified time.
quhichis
Input and Output
PrOVIGingofT suppling
conneled Provision
The algorithm should be able to take inputs and give the desired definite result after processing.
beginning cleorly degined or gired
Definiteness
Each step of algorithm must be defined unambiguously clearly
Generality
The algorithm should apply to a wide range of inputs. That means when you need to solve same
kind of problem with different inputs, then it can be done by following the steps of same algorithm.

ACTIVITY TIME

1 Write an algorithm to prepare a sandwich of your choice.

35
RISEUP COMPUTERS-8

elaborate
A computer program can be viewed as an LEARNING BEYOND
algorithm. In mathematics and computer science, an
algorithm usually means asmallprocedure that solves a
problemto get the desired result( By using highly eficient Google makes changes
algorithms, developers can ensure their programs run as fast
as possible and use minimal system resources) Definitely,
to its search algorithm
roughly 500 times per year.
most of the algorithms created are not perfect in the first
attempt. Developers often improve existing algorithms and
include them in future software updates. When you see a
new version of a software program that has been 'optimised LEARNING BEYOND
or has faster performance; that definitely means the new
version are based on the algorithms that are more efficient.
Pseudo code is a simple
Algorithms are mostly writteninsimple Englishlanguage. technique of writing
However, for writing an algorithm for a computer program programming language
sometimes pseudo codes and sometimes some graphics are
used. Once we have an algorithm, we can easily translate it in English by usingshort
into a computer program in some programming language. phrases.

Steps to Develop an Algorithm


1. Obtain adescription of the problem weakest part of the
This step ismuch more difficult than it appears, but this is often the
one or more of the
process. It is quite common for a problem description to suffer from
following types of defects:
The description relies on unstated assumption
The description is ambiguous
The description is incomplete or
The description has internal contradictions
These defects are mainly due to the fact, that natural languages (English, Hindi, French, etc.)
are rather imprecise and sometimes ambiguous. Therefore, it is the developer's responsibility
to identify the defects in the description of aproblem, and to work with the client to find the
remedy for those defects.
2. Analyse the problem
The purpose of this step is to determine both the starting and ending points for solving the
problem. Developer should know the kind of inputs required and available. The kind of
desired output should be clear.
3. Develop astep wise solution for the problem
As we know an algorithm is aplan for solving aproblenm, but plans come in several levels of
detail. It is usually better to start with a high-level algorithm that includes the major part of
a solution, but leaves the details until later. This means the major steps (to solve the problem)
should be written first, and then the other steps can be added later.

36
A Refine the algorithm by adding more detail
Ahigh-levelalgorithm shows the major steps that necd to be followed to solvea
problem. Now we need to add details to these steps. But how much detail should we add?
Unfortunately, the answer to this question depends on the situation. We have to consider
who (or what) is going to implement the algorithm and how much that person (or thing)
already knows how to do.
When our goal is to develop algorithms that will lead to computer programs, we need to
consider the capabilities of the computer and provide enough detail so that anyone can use
these algorithms to write a computer program.
5. Review the algorithm
First, we need to work through the algorithm to
determine whether it will solve the original problem Test Your Skill
or not. Once we are satisfied that the algorithm does
provide a solution to the problem, we start to look Can you change the
for other things. Algorithm should be refined so that sequence of steps in
it is generalised i.e., it can be used to solve the same an algorithm?
problem in different situations.

ACTIVITY TIME

1. Refine the algorithm of preparing a sandwich of your choice.

37
- 8
RISEUP COMPUTERS

Flowchart
(sequence of steps and decisions) needed
Alowchart is a visual representation of the algorithm shape. Steps are linked by
to solve a problem. Each step in the sequence is denoted with a definitemake the flow of the chart
to
using connecting lines' and directional arrows. It is a good practice
from top to bottom and from right to left.
Symbols Used in Flowchart
Some of the commonly used symbols for drawing a flowchart are listed below.
1. Terminal/Terminator

or

The Terminator symbolis used to show where your flow begins or ends. An oval shape
represents it. Developers generally use the words like 'Start, 'Stop Begin, End inside
the terminator object to make things more obvious.
Start
End

2. Process

Flowchart Processobject is used to illustrate an action, operation or a process. These are


represented by rectangles. The text in the rectangle mostly includes a verb. Examples include
Pick a card; Try Again, Add the numbers, etc.

Tie a knot X= 2*Y

3. Data

The Data object, often referred to as the I/O shape shows the Inputs to and Outputs from
a process. This is denoted by a parallelogram.
Enter two
whole numbers,
Display the
product

38
4. Decision/Conditional

A
rhombus shape or adiamond represents Decision object. This object is used to represent
the steps which contains a question. The answer to the question determines the arrows
coming out of the diamond. Two arrows come out of it. One corresponding to Yes' or True
and the other for No' or 'False The arrows should always be labelled to avoid confusion in
the process flow.

Is Sita taller No
than Gita?

Yes
5. Document

Document object is a rectangle with awave-like base. This shape is used to represent
adocument or report in aflowchart.
Student's
Attendance
Report

6. Stored database

Stored database is the direct Data object in a flowchart, which represents the information,
stored in asecondarystorage device and can be accessed directly.
Student
Database

39
RISEUP COMPUTERS - 8

7. Connector

Ihis is a small circle shaped object. It is required when the flowchart is to0 big and cannot ft
connector by writing a letter or number
In d single page. In that situation develoners use a on the next page.
hside it. Theconnector with the same letter or number is used to continue

Many more symbols are used in advanced flowcharts prepared by professionals.


Now let us try to prepare aflowchart for aprogram to 'read mail from mail box.
START

H
Open the website

Enter your user ID


and password.

Is the ID NO
registered on Display an error
the website? message

Yes
LEARNING BEYOND
Open the inbox and
read messages

Log out

GMail
STOP Gmail is a popular website
that provides e-mail services.

40
Let us take another example of preparing aprogram of displaying astudent detail with agiven ID.
Algorithm
1. Enter the ID of the student.
2. Take data from the student database.
3. Compare one record with the ID,
4. Is the result of comparison true.
Then display the student detail
b. Else check whether it is last record
i. If yes display message 'no record found'
ii. Else move to next record and again go to step 3.
Flowchart

START

Enter the ID
of the student
Move to next record

Database
Student
Check the student ID in
the student database

Does the ID NO
NO Is it the last
match with
record?
the database
record?

Yes Yes

Display student Display message


'No record found'
detail

STOP

41
RISEUP COMPUTERS 8

Let Us Remember

An algorithm is a procedure or formula for solving a problem, based on a sequence


of specified actions or steps.
An algorithm should be precise, with finite steps and general in character.
Aflowchart is a visual representation of the algorithm.
Flowchart is drawn with some universally accepted symbols.
Terminal symbol (starting and ending symbol) is oval in shape.
Shape of Input/Output symbol is parallelogram.
Shape of process symbol is a rectangle. B sequence works
Shape of decision symbol is a rhombus.
Shape of a stored database is a cylinder. in a wa', a collection
never can 33
Connector is of smallcircular shape.
George Murray

LET'S PRACTICE
(Navigation/Practical Based Worksheet)
1. Draw the symbol of the objects used in a
flowchart.
a. Input/Output box

b. Process

C. Database

42
d. Connector

e Terminator

2. Drawa flowchart for a program to display the


sum of two numbers.

START

Read ayb

SOm Q+b

Baplay sum
STOP

43
RISEUP COMPUTERS -8

LET'S PRACTICE (Theory-based Worksheet)


1. Fill in the blanks.
a.
Every problem solution starts with a.
for factorisation.
D.eaay lomjan_developedthe earliest known algorithms
C.
An algorithm is generally written in Englsh number
language.
of instructions or steps.
d. The algorithm must stop after a
e.
The algorithm should apply to a wide range of inputs.
f. The oval shape symbol in a flowchart is known as
Tesminal /Terminator
2. Choose the correct option.
a.
Which of the following is a characteristic of a good algorithm?
i. uniqueness ii. finiteness ii. precision j v all of these

b. Approximately, how many times per year, Google makes changes to its search algorithm?
i. 5 times jH. 500 times iii. 50 times iv. never

c.
The last step of developing an algorithm is
get the details of a problem ii. refine the steps of algorithm
iii. analyse the problem jx review the algorithm
d. Name of the starting symbol of a flowchart is
1. process H terminal ii. input/output iv. start
e. The symbol used to link two sub parts of a flowchart
i. terminal j í connector i. database
iv. rectangle
3. Write True or False.

a. We use algorithm in our daily life also.


True
b. Google never makes changes to its search
algorithm.
not Aalse
C. A
good algorithm should'have many loops in it.
Aalse

44
A Itis necessary to have a proper description of the
before writing the algorithm. problem
Troe
Steps in flowchart are not linked with any symbol. Palse
f We use aeircBe. for denoting a processing step in a Lalse
flowchart.
4. Answer the following questions.
a. What do you mean by algorithm?

b. Define flowchart.

C. List the qualities of a good algorithm.

d. Write an algorithm to find the sum ofn natural numbers.

45
RISEUP COMPUTERS

Write the use of connector and decision symbol in a flowchart.

KIDS ZONE
a.
Write an algorithm for reaching school when it is raining and compare your steps with
that of your partner.
b. Prepare a flowchart of any rule of mathematics learnt in class 8
and display it on the
bulletin boardof your class.
C.
Discuss in pairs about the advantages of writing algorithms.

TEACHER'S CORNER
Discuss many algorithms related to real life (hint: use current
affairs).
Discuss the difficulties the children can face while
analysing bThe first step in solving
a problem. aproblem is to recognise
Show presentations to illustrate the different that it does exists. 3
a flowchart. symbols used in
Provide children opportunities through - Zig Ziglar
activity on algorithms and flowcharts. projects for hands on

46

You might also like