Algorithm Design-notes
Algorithm Design-notes
2. Writing algorithms that solve problems using structured English, flowcharts, and
pseudocode.
Overview
To design a computer system that performs specific tasks or solves problems, the task
must be clearly defined with a plan of what will be computed and how it will be
computed.
• Tools and techniques to create software solutions that work with hardware.
• The importance of practice in developing computational thinking skills.
• Using flowcharts and pseudocode to plan and check solutions before actual
programming.
• Coding to test the viability of a solution.
Programming Languages
• Java
• Python
• VB.NET
Terms,
Using Abstraction
• Abstraction helps to focus only on the important details necessary for solving a
problem
• Examples include simplified maps (see figure below), which only display
essential information like roads and town names.
Benefits of abstraction
Using Decomposition
• Decomposition breaks complex problems into smaller parts that are easier to
solve individually.
• Once each part is manageable, it can be developed into a solution and
integrated into the final program.
• Pattern recognition is used in decomposition to reuse parts of solutions that are
similar to other problems.
• Modular Programming (Figure below) demonstrates decomposition by
dividing the program into smaller modules, each performing a specific
function. This saves development time and allows code reuse.
Note,
•
• Algorithm: A step-by-step process to solve a problem.
• Flowchart: A diagrammatic representation of an algorithm.
• Pseudocode: Plain language representation of an algorithm to show logic
before coding.
Inputs:
Outputs:
Pseudocode:
1. Start
6. End
Flowchart
A simple visual showing the steps with input, calculation, and output boxes.
Writing Simple algorithms Using Pseudocode
o Keywords such as IF, ELSE, and CASE must be written in uppercase and
are indented by two spaces.
Identifiers:
o Identifiers should start with a letter and include only characters A–Z, a–z,
0–9, and _.
Common Keywords:
• Operators:
o Addition: +
o Subtraction: -
o Multiplication: *
o Division: /
Single Choice
ENDIF
ELSE
ENDIF
Without Alternatives,
CASE OF Direction
"N": X <- X + 1
"S": X <- X - 1
ENDCASE
With Alternatives:
CASE OF Direction
"N": X <- X + 1
"S": X <- X - 1
ENDCASE
Relational Operators in Pseudocode
• =: Equal to
1. Python:
o Example:
print("I win")
Note,