Professional Documents
Culture Documents
KS3 Presentation - 09 Introduction To Algorithms
KS3 Presentation - 09 Introduction To Algorithms
KS3 Computing
Introduction to
algorithms
teachcomputerscience.com
2
Lesson Objectives
teachcomputerscience.com
1.
Content
teachcomputerscience.com
4
Introduction
To program a computer, certain sets of logical instructions need to be
provided.
Sets of logical instructions for a computer can be designed only when the
programmer thinks in the same way that a computer processes the
instructions.
Computational thinking is a thought process involved in formulating a
problem and expressing its solution in such a way that computers can
effectively carry it out.
teachcomputerscience.com
“As soon as an Analytical Engine exists, it
will necessarily guide the future course of
the science. Whenever any result is
sought by its aid, the question will then
arise — by what course of calculation can
these results be arrived at by the machine
in the shortest time?”
-Charles Babbage, Passages from the life of a philosopher
5 teachcomputerscience.com
6
Software development
Developing a software is a complex process as it involves:
• Innovative thinking processes. It is quite difficult to create new software which
has not been done before.
• Complex testing procedures to check the functionality of software. Software
does not obey physical laws and to determine its properties, its developer
must test it under different conditions.
Software engineering describes structured methodology and techniques to
develop new software. Testing software is now made into a disciplined process
too.
teachcomputerscience.com
7
Computational thinking
Computational thinking is beneficial in many ways and has changed
the way computer scientists look at the software development process
to be a more structured process.
Using this, a complex problem is understood by breaking it into
various modules that can be further solved individually. The solution
obtained may involve a computer, a human, or both.
teachcomputerscience.com
8
Computational thinking
The components of computational thinking are:
Abstraction
Decomposition
Algorithm design
teachcomputerscience.com
9
Algorithm
An algorithm is generally written using pseudocode or flowcharts.
Pseudocode is a readable description of what a computer program
will do.
A flowchart depicts the steps and order to be followed to perform a
task.
Designing a proper algorithm plays an important role in the software
development process.
teachcomputerscience.com
10
Designing an algorithm:
Robotic vacuum cleaner
It moves forwards, backwards,
leftwards and rightwards to clean a
floor.
A simple algorithm is given for
programming the movement of the
vacuum cleaner.
teachcomputerscience.com
11
Place robotic vacuum
cleaner at a corner of a
room Move forward 10 steps
teachcomputerscience.com
12
Refining an algorithm:
Robotic vacuum cleaner
This algorithm can be made efficient
by using iteration.
Iteration is the technique of repeating
a process.
The motion of turning and moving 10
steps can be placed in an iteration.
teachcomputerscience.com
13
Place robotic vacuum
cleaner at a corner of a
room Move forward 10 steps
Repeats
15 times
teachcomputerscience.com
14
Refining an algorithm:
Robotic vacuum cleaner
A procedure is a list of sequences that
can be used several times in a
program.
Programmers need not insert the
complete list of sequences.
It is enough to call the procedure to
execute it in a program.
The details of the procedure are
hidden from the user. This is called teachcomputerscience.com
procedural abstraction
15
teachcomputerscience.com
16
Assigning a Value
teachcomputerscience.com
18
Pseudocode Description
teachcomputerscience.com
19
Conditional statements
teachcomputerscience.com
20
Conditional statements
If… then… statement Case statements
IF condition CASE Choice OF
THEN PRINT “ Yes ” 1 : PRINT “You entered Choice 1”
ELSE PRINT ”No ” 2 : PRINT “You entered Choice 2”
ENDIF 3 : PRINT “You entered Choice 3”
OTHERWISE PRINT “Not a valid choice”
ENDCASE
teachcomputerscience.com
21
Pseudocode Description
teachcomputerscience.com
22
Operator Comparison
Operators for < Less than
comparison > Greater than
== Equal to
<= Less than or equal to
>= Greater than or equal to
!= Not equal to (in Python)
<> Not equal to (in SQL)
() Group
AND Both
OR Either
NOT Complement
teachcomputerscience.com
23
Case statement
Pseudocode Description
Loop statements
teachcomputerscience.com
26
Output Welcome
Welcome
Welcome
Welcome
Types of loop statements Welcome
Welcome
Welcome
Welcome
Welcome
FOR... TO… NEXT REPEAT... UNTIL WHILE… DO... Welcome
FOR Counter ← 0 TO 10 Counter ← 0 Counter ← 0
PRINT “Welcome” REPEAT WHILE Counter < 10 DO
NEXT PRINT “Welcome” PRINT “Welcome”
Counter ← Counter + 1 Counter ← Counter + 1
The value of counter
starts from 0 and is UNTIL Counter < 10 ENDWHILE
incremented in each
iteration. So, the
range of counter is 0 teachcomputerscience.com
to 9.
27
Flowchart symbols
No
teachcomputerscience.com
28
Algorithm
A problem is broken into a series of logical steps called an
algorithm.
For example: to design a program to multiply two numbers,
logical steps have to be provided. Repeated addition is the
widely used logic behind multiplication.
teachcomputerscience.com
29
Algorithm design
Flowchart Pseudocode
A flowchart depicts the steps and order Pseudocode is a method of representing
to be followed to perform a task. an algorithm using simple words and
mathematical operators.
teachcomputerscience.com
30
Flowchart: Example 1
This flowchart checks whether a
number is odd or even.
A decision box is used to check
whether the remainder of a
number divided by 2 is 0 or not.
This decision box has one entry
point and two exit points.
Sometimes a decision box may
have more than two exit points.
teachcomputerscience.com
31
Pseudo code:
Example 1
INPUT Num
IF Num MOD 2 = 0
THEN PRINT Num, “is an even number”
ELSE PRINT Num, “is an odd number”
ENDIF
teachcomputerscience.com
32
Pseudo code:
Example 2
An algorithm to print the numbers:
1 2 3 4 5 using loop statement is given.
Counter ← 1
WHILE Counter < 6 DO
PRINT Counter
Counter ← Counter + 1
ENDWHILE
teachcomputerscience.com
33
Loop statements are used to FOR... TO… NEXT Flowchart symbols are used to
represent the start and end of a
perform a part of the REPEAT... UNTIL
program, process, output and
algorithm multiple times. WHILE… DO... decision.
teachcomputerscience.com
2.
Activity
teachcomputerscience.com
35
Activity-1
Duration: 20 minutes
teachcomputerscience.com
36
Activity-2
Duration: 15 minutes
teachcomputerscience.com
3.
End of topic questions
teachcomputerscience.com
38
teachcomputerscience.com
39
teachcomputerscience.com