0% found this document useful (0 votes)
13 views11 pages

Algorithm Design and Problem Solving

The document discusses computational thinking skills used to solve problems algorithmically including abstraction, decomposition, pattern recognition, and algorithms. It defines algorithms as a sequence of defined steps to complete a task and describes control structures like sequence, selection, and repetition that determine statement execution order.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views11 pages

Algorithm Design and Problem Solving

The document discusses computational thinking skills used to solve problems algorithmically including abstraction, decomposition, pattern recognition, and algorithms. It defines algorithms as a sequence of defined steps to complete a task and describes control structures like sequence, selection, and repetition that determine statement execution order.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

CHAPTER 9

Algorithm Design and


Problem Solving
◦ 9.1 Computational thinking skills

Computational thinking is used to study a problem and formulate an effective


solution that can be provided using a computer. There are several techniques
used in computational thinking,:
 Abstraction,
 Decomposition
 pattern recognition.
 Algorithms
Abstraction
◦ Def: The process of extracting information that is essential, while ignoring what is not
relevant, for the provision of a solution.
◦ This is an essential part of computational thinking. It enables computer scientists to develop clear models for
the solution to complex problems.
◦ Abstraction involves extracting information that is essential, while ignoring what is not relevant for the
provision of a solution, only including what is necessary to solve that problem.
◦ Many items in common, everyday use are the result of using abstraction; for example, maps, calendars and
timetables.
◦ Maps use abstraction to show what is required for a specific purpose; for example, a road map should only
show the necessary detail required to drive from one place to another.
◦ (Refer pg. no. 179)
Decomposition
◦ – Def : The process of breaking a complex problem into smaller parts

◦ This is also an essential part of computational thinking. It enables computer scientists to divide a complex
problem into smaller parts that can be further subdivided into even smaller parts until each part is easy to
examine and understand, and a solution can be developed.
◦ Decomposition leads us to the concept of program modules and use of functions and procedures.
Pattern recognition
◦ This is used to identify those parts that are similar and could use the same solution. This leads
to the development of reusable program code in the form of subroutines, procedures and
functions.

◦ Eg: Sorting and Searching algorithms.


9.2 Algorithm
◦ an ordered set of steps to be followed in the completion of a task
◦ Def: A sequence of defined steps that can be carried out to perform a task
◦ There are several methods of writing algorithms:
◦ » Structured English is a method of showing the logical steps in an algorithm, using an agreed subset of
straightforward English words for commands and mathematical operations to represent the solution. These steps can be
numbered.
◦ » Flowchart shows diagrammatically, using a set of symbols linked together with flowlines, the steps required for a
task and the order in which they are to be performed. These steps, together with the order, are called an algorithm.
Flowcharts are an effective way to show the structure of an algorithm.
◦ » Pseudocode is a method of showing the detailed logical steps in an algorithm, using keywords, identifiers with
meaningful names, and mathematical operators to represent a solution. Pseudocode does not need to follow the syntax
of a specific programming language, but it should provide sufficient detail to allow a program to be written in a high-
level language.
Control Structures / Control Constructs
◦ -determines the order in which statements are executed.
1. Sequence
2. Selection
3. Repetition

(Assignment)
Sequence
sequence involves simple steps which are to be executed one after the other.
Each step is executed in the same order in which it appears
In pseudocode this would be:
process 1
process 2
process 3
...........
process n
Sequence cont:

Eg:
◦ Write an algorithm using pseudocode to input mark 1 and mark 2 and get the total and average of them.
Begin
total=0
Avg=0
INPUT Mark1, Mark2
total=Mark1+Mark2
Avg=total/2
OUTPUT total, Avg
End.
Selection
◦ Under certain conditions some steps are performed, otherwise different (or no) steps are performed.

IF <condition> CASE OF <identifier>


THEN <value 1> : <statement>
<statements> <value 2> : <statement> ...
ELSE OTHERWISE
<statements> <statement>
ENDIF ENDCASE
Repetition / Iteration / Looping
◦ A sequence of steps is performed a number of times until condition satisfied or not satisfied.
◦ Count-controlled (FOR) loops
FOR <identifier> ← <value1> TO <value2> <statements> NEXT
◦ Pre-condition loop
WHILE <condition> DO <statements> ENDWHILE
◦ Post-condition loop
REPEAT <Statements> UNTIL <condition

You might also like