Computer - CH - 3 .Algorithms and Flowcharts
Computer - CH - 3 .Algorithms and Flowcharts
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
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.
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
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
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
H
Open the website
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
STOP
41
RISEUP COMPUTERS 8
Let Us Remember
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
START
Read ayb
SOm Q+b
Baplay sum
STOP
43
RISEUP COMPUTERS -8
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.
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.
45
RISEUP COMPUTERS
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