Learning Focus: Describe algorithms through
varied examples.
Activity 1: Individual Listing
Guide Question:
➢ “If you cook noodles, what’s the very first thing you
do?”
➢ “If you prepare for school in the morning, what’s the
very last step before leaving the house?”
Discussion:
“What everyday examples did you recognize, maybe getting
ready, cooking, or online searches?”
Bridge to lesson:
“Algorithms aren’t just for computers. They’re everywhere
even in how you get ready for school. Today, we’ll learn how
to write your own daily-life algorithms, then move on to using
them to solve real problems with code.”
Describe algorithms through varied examples
➢ Algorithm - Algorithm - is a step-by-step set of
instructions that you follow to finish a task or solve a
problem.
• Just like a recipe for cooking: it tells you what to do
first, second, and last.
• Computers also need recipes algorithms to know what
to do.
➢ Algorithm - is a precise, finite sequence of steps
designed to solve a problem or perform a task. These
well-defined instructions take an input, process it
through logical rules, and yield an output all within a set
number of steps.
Relatable Examples:
• Cooking noodles: Boil water → Add noodles → Add
seasoning → Serve.
• Morning routine: Wake up → Brush teeth → Take a bath
→ Put on uniform → Eat breakfast → Go to school.
• Searching for a word in a book: Check page by page until
you find it. That’s an algorithm!
➢ An algorithm is a finite sequence of well-defined
instructions designed to solve a specific problem.
It always has:
Input → the data you start with (like numbers, text, or
even ingredients).
Process → the steps you perform (like adding, sorting, or
mixing).
Output → the result after following the steps (like the
answer, sorted list, or finished dish).
➢ Why Are Algorithms Important?
• Efficiency – Good algorithms solve problems faster
(e.g., searching Google quickly).
• Clarity – They make it easier for humans and
computers to understand steps.
• Problem-solving – They help us plan before coding, just
like architects make blueprints before building.
➢ 5 Essential Components of Algorithm Development
Step 1: Obtain a description of the problem.
Step 2: Analyze the problem.
Step 3: Develop a high-level algorithm.
Step 4: Refine the algorithm by adding more detail.
Step 5: Review the algorithm
Learning Focus: Representations of Algorithms
Single routine (algorithm) can be written in different
representations.
Task: Making a Cup of Coffee
Directions: Perform simple task following different
representations.
Step 1 – Present in Natural Language (Narrative)
1. Boil water.
2. Put coffee powder into a cup.
3. Pour hot water into the cup.
4. Stir well.
5. Add sugar or milk if desired.
6. Drink the coffee.
Single routine (algorithm) can be written in different
representations.
Step 2 – Present in Pseudocode
Write the same process in pseudocode.
➢ Pseudocode looks like programming code but is not tied to
any specific language. It mixes plain English with simple
computer-like commands.”
Single routine (algorithm) can be written in different
representations.
Step 2 – Present in Pseudocode
START
BOIL water
PUT coffee powder into cup
POUR hot water into cup
STIR mixture
IF desired THEN
ADD sugar or milk
END IF
DRINK coffee
END
Single routine (algorithm) can be written in different
representations.
Step 3 – Present in Flowchart
Finally, the same process in a flowchart, which is a visual
way of showing the steps using symbols.
Start
Step 3 – Present in Flowchart
Boil Water
Put coffee powder into cup
Pour hot water into cup
Stir mixture
Yes No
Add sugar or milk?
Add sugar/milk
Drink
Stop
Activity. Brushing Teeth Algorithm
Directions: Convert a familiar daily routine into pseudocode
and a flowchart. Create your own algorithm for brushing
your teeth.
A. Step 1: Natural Language
B. Step 2: Convert Natural Language to Pseudocode
C. Step 3: Draw a Flowchart
Common Ways to Present an Algorithm
1. Natural Language (Narrative) Describes the algorithm
using everyday language. It's easy to understand but can
be verbose and ambiguous, making it less suitable for
complex or technical tasks. This Natural Language
presentation is simple and intuitive, it uses everyday
instructions without loops, conditions, or pseudocode
syntax. It’s a friendly way to explain the process to
someone unfamiliar with technical formats.
Natural Language
Strengths:
Very easy to understand.
No special symbols needed.
Useful for first drafts or explaining to non-technical people.
Weaknesses:
Can be vague or ambiguous.
Not suitable for complex tasks.
Computers cannot execute it directly.
Common Ways to Present an Algorithm
2. Pseudocode A structured, language-independent code-
like description mixing natural language with
programming constructs (e.g. IF, FOR, INPUT, PRINT,
END IF). Pseudocode serves as a human-readable bridge
between ideas and real code, focusing on logic over syntax
and allowing efficient planning and communication.
Pseudocode
Strengths:
More precise than natural language.
Easy to read for both humans and programmers.
Helps in planning code before writing in an actual language.
Weaknesses:
Requires some knowledge of coding style.
Still not directly runnable by a computer.
Write Guidelines:
Use capitalized keywords, paired constructs (e.g. IF/ENDIF),
and consistent indentation
Common Ways to Present an Algorithm
3. Flowchart A graphical representation using standard
symbols ovals for start/end, rectangles for actions,
diamonds for decisions, parallelograms for input/output
and arrows that define control flow.
Flowcharts excel at showing branching and flow visually
and are especially helpful for simple processes or for
communicating with non-programmers.
Flowchart Description
1. Start (Oval)
2. Preparation: (Hexagon) declaration of variable.
3. Input: (Parallelogram) enter the value of variables A and B.
4. Process: (Rectangle) compute the sum (Sum = A + B)
5. Output: (Parallelogram) Display the result (Sum)
6. End (Oval)
Daily Life Connection:
Imagine I’m a robot. Tell me how to make a sandwich step by
step.
• As students give instructions, the teacher acts like a robot
but follows them literally (e.g., if they say, ‘Put peanut butter’
without saying ‘open the jar’, teacher pretends to struggle).
• This creates humor but also shows gaps in instructions.
Breaking Problems into Smaller Steps
Stepwise Refinement means starting with a high-level step and
then breaking it down into smaller and more detailed sub-steps
until it becomes clear enough to translate into pseudocode or
actual code.
Breaking Problems into Smaller Steps
Example – Making Spaghetti
High-Level Steps (Natural Language)
1. Cook spaghetti.
2. Prepare sauce.
3. Serve meal.
Breaking Problems into Smaller Steps
Refinement (More Detailed):
1.1 Boil water. 2.4 Add tomato sauce.
1.2 Add pasta to boiling water. 2.5 Simmer for 15 minutes.
1.3 Cook pasta for 10 minutes. 3.1 Place pasta on plate.
1.4 Drain water. 3.2 Pour sauce over pasta.
2.1 Heat oil in pan. 3.3 Add cheese on top.
2.2 Add garlic and onion.
2.3 Add ground meat.
Recognizing Alternative Algorithms
1. Understanding the Concept
For most problems in computer science (and in real life),
there is rarely only one way to solve them. “Alternative
algorithms” means that you can design different step-by-
step procedures (algorithms) to achieve the same outcome.
Each may have different approaches, efficiencies, or
complexities.
Recognizing Alternative Algorithms
2. Common Alternative Approaches
• Brute Force: Try every possible option (e.g., try every subset).
• Divide and Conquer: Split the task into smaller tasks, solve
them independently, and combine the results.
• Greedy: Always select the ‘best’ choice at each step.
• Dynamic Programming: Break the problem into sub-
problems, save results to avoid redundant work.
• Using Built-In Functions/Libraries: Sometimes a language
provides a function that already solves the problem efficiently.
Recognizing Alternative Algorithms
3. Why Consider Alternatives?
• Efficiency: Some algorithms are faster (lower time
complexity) or use less memory (lower space complexity).
• Simplicity: One approach may be easier to understand or
implement.
• Context: The best approach may change depending on the
input size or special constraints.
Activity2: Same Problem, Different Paths
Give a quick challenge:
“How can you compute the area of a rectangle (L × W)?”