Algorithm Design and Problem Solving
Algorithm Design and Problem Solving
◦ 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.
(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.