0% found this document useful (0 votes)
7 views8 pages

Algorithm Design-notes

The document outlines key learning objectives in algorithm design and problem solving, emphasizing computational thinking skills such as abstraction and decomposition. It covers techniques for writing algorithms using structured English, flowcharts, and pseudocode, as well as the importance of testing solutions. Additionally, it introduces programming languages like Java, Python, and VB.NET, and provides guidelines for writing clear and effective pseudocode.

Uploaded by

levi makokha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
7 views8 pages

Algorithm Design-notes

The document outlines key learning objectives in algorithm design and problem solving, emphasizing computational thinking skills such as abstraction and decomposition. It covers techniques for writing algorithms using structured English, flowcharts, and pseudocode, as well as the importance of testing solutions. Additionally, it introduces programming languages like Java, Python, and VB.NET, and provides guidelines for writing clear and effective pseudocode.

Uploaded by

levi makokha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

Algorithm Design and Problem Solving

Key Learning Objectives

1. Computational thinking skills (abstraction and decomposition).

2. Writing algorithms that solve problems using structured English, flowcharts, and
pseudocode.

3. Stepwise refinement for systematic problem solving.

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.

Techniques that will be covered in this section

• 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

What you should already Know,

• Procedure – A block of code designed to perform a specific task.


• Function – A type of procedure that returns a value.
• Algorithm – A step-by-step process or set of rules to solve a problem.
• Structured English – A plain language approach to describe algorithms.
• Flowchart – A visual representation of an algorithm.
• Pseudocode – Writing algorithms in plain text before implementing them in a
programming language.
Computational Thinking Skills

Terms,

• Abstraction – Focusing on important details while ignoring irrelevant ones.


• Decomposition – Breaking down complex problems into smaller, manageable
parts.
• Pattern recognition – Identifying similarities in problems to use similar solutions.

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

• Reduces unnecessary details, making solutions easier to develop and


understand.
• Results in smaller, faster programs that are easier to download and execute.
• Enhances customer satisfaction by delivering more targeted solutions.

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,

• Computational thinking involves breaking down problems using abstraction


and decomposition.
• Abstraction focuses on essential details, simplifying complex problems.
• Decomposition divides problems into smaller, solvable parts, allowing easier
integration of solutions.
• These skills are critical in programming and software design, leading to
efficient, scalable, and reusable code solutions.
Writing Algorithms that Provide Solutions


• 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.

Steps for Designing Algorithms:

• Understand the problem.


• Identify inputs and expected outputs.
• Plan the steps to solve the problem.
• Write the algorithm using flowcharts and pseudocode.
• Test the algorithm to ensure it works correctly.
Example 1: Write an Algorithm to Find the Average of Three Numbers

Inputs:

• Three numbers: n1, n2, n3.

Outputs:

The average of the numbers.

Pseudocode:

1. Start

2. Input three numbers: n1, n2, n3


3. Calculate the sum: sum = n1 + n2 + n3

4. Calculate the average: average = sum / 3

5. Output the average

6. End

Flowchart

A simple visual showing the steps with input, calculation, and output boxes.
Writing Simple algorithms Using Pseudocode

Structure and Indentation:

o Pseudocode uses 4 spaces for indentation.

o Keywords such as IF, ELSE, and CASE must be written in uppercase and
are indented by two spaces.

Identifiers:

o Use meaningful names (e.g StudentName for storing a student's name).

o Identifiers should start with a letter and include only characters A–Z, a–z,
0–9, and _.

o They are case-insensitive.

Common Keywords:

o INPUT: To take user input.

o OUTPUT: To display values or messages.

o Variables: Used to store values (e.g., Counter <- Counter + 1).

Assignment and Operators

• Assignment: Use <- for assigning values (e.g X <- 10).

• Operators:

o Addition: +

o Subtraction: -
o Multiplication: *

o Division: /

o String concatenation: &

IF Statements (Conditional Logic)

Single Choice

IF MyValue > YourValue THEN

OUTPUT "I win"

ENDIF

Choice with Alternatives

IF MyValue > YourValue THEN

OUTPUT "I win"

ELSE

OUTPUT "You win"

ENDIF

Multiple Choices (CASE Statements):

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

OTHERWISE: OUTPUT "Error"

ENDCASE
Relational Operators in Pseudocode

• =: Equal to

• <>: Not equal to

• >: Greater than

• <: Less than

• >=: Greater than or equal to

• <=: Less than or equal to

Programming Language Comparisons

1. Python:

o Use colons : to indicate the start of clauses.

o Example:

if MyValue > YourValue:

print("I win")

Note,

• Always format pseudocode properly to enhance readability and follow the


conventions of the Cambridge International AS & A Level standard.

PERFORMING ITERATION USING FOR, REPEAT–UNTIL AND WHILE LOOPS(nxt lesson)

You might also like