Unit 3: Algorithmic Thinking and Problem Solving
Computer Education Class 6 — English (Sindh Textbook Board)
Source: Computer Education Class 6, Sindh Textbook Board, Jamshoro.
About this source
Textbook text is reproduced for free educational study. All solutions, explanations, practice questions, diagrams and teacher's guides are original work by 100MCQs. 100MCQs is an independent site and is not affiliated with or endorsed by the Sindh Textbook Board. Read our Disclaimer.
Unit 3: Algorithmic Thinking and Problem Solving
Student Learning Outcomes
After the completion of this unit students will be able to:
- Define and identify a problem and differentiate between simple and complex problems.
- Solve any problem by following the 6 steps problem solving guide.
- Analyze different steps to break down a problem.
- List benefits of algorithmic thinking.
- Recognize that algorithms are sequence of precisely described instructions.
- Define conditional/selection statements that decide whether certain instructions should run or not.
- Identify loops and analyze how they allow instructions to be repeated.
- Analyze ways to solve a problem by using a combination of sequence, selection, and repetition.
Introduction to the Unit
In this unit we are going to learn how to solve problems in a well manner, which is super important for everything we do, like at school and even when we grow up and have jobs. This unit also introduces the fundamental principles of algorithmic thinking, highlighting its role as a systematic approach to breaking down problems into manageable components and planning step-by-step strategies for solution.
3.1 Problem
A problem is something (event, task, situation) that needs to be solved. It is like a puzzle or question for which a solution must be found. Problems can be big or small, and can be from the real-world or pointed out by someone. They can be anything from real life situations to math problems, for instance.
Here are three examples of problems:
- You are walking in the park, and you see a lost puppy. What would you do to help the puppy find its way home?
- Your favorite toy is broken. What are some ways you can try to fix it?
- Aslam has 3 bags of coins, and each bag has 5 coins. How many coins does Aslam have in total? (3 × 5 = 15 coins.)
3.2 Simple and Complex Problems
3.2.1 Simple Problems
Simple problems are like puzzles that are easy to solve. They usually have a clear question with an answer that you can find using basic steps.
For example: bake a cake or cook instant noodles for lunch.
- Simple problems can be solved by simply following the recipes.
- No expertise is required to solve simple problems.
3.2.2 Complex Problems
Complex problems are like larger puzzles that need more thinking. They might have many steps or need different ways to solve them.
For example:
- Calculating the Least Common Multiple (LCM).
- Determining if a number is prime or not.
- A book costs 500 Rs, more than twice the cost of a pen. If the total cost of the book and the pen is 800 Rs, how much does each item cost?
These types of problems can be solved by breaking them into many simple problems. Site summary: This is how we can identify a complex problem: it has many steps, or it needs to be broken into smaller problems before it can be solved.
Figure 3.3 shows how the LCM of 10, 18 and 20 is calculated by the division method. At each step we divide by a prime number and bring down the numbers that cannot be divided.
| Divisor | Numbers |
|---|---|
| 2 | 10, 18, 20 |
| 2 | 5, 9, 10 |
| 3 | 5, 9, 5 |
| 3 | 5, 3, 5 |
| 5 | 5, 1, 5 |
| — | 1, 1, 1 |
LCM = 2 × 2 × 3 × 3 × 5 = 180. (This working has been checked: LCM of 10, 18 and 20 is 180.)
3.3 Problem Solving
We solve various problems every day and every problem is unique in nature. Some problems are difficult and require more attention to find the solution. Problem solving is a process of identifying and finding the most effective solution to a problem. The skill of problem solving can be mastered by following a systematic and well-organized approach, as shown in Figure 3.4.
Step 1: Identify the problem
- State what the problem is. For example: "Manahil wants to buy a birthday gift for her friend Moomal."
- Be clear about when, where, and why it is a problem. For example: "Manahil wants to buy a birthday gift that Moomal will like, and which will make their friendship stronger."
Step 2: Explore information and ideas
- Write down all the ideas you can think of, even if they seem wrong or not good.
- Use your imagination to think of some cool ideas you would not have thought of before.
In this case, Manahil can think of the following possible solutions:
- A book that her friend mentioned that she wants.
- A board game, they can play together.
- A gift card to their favorite store.
- A personalized photo album of their memories together.
Step 3: Analyze the problem and evaluate alternatives
- We look for ideas we don't like as much and say bye-bye to them.
- We put the ideas we like the most on a special list.
- We think about good and not so good things about each idea to decide which one is best.
For example, Manahil came to the following conclusion for each possible solution:
- The book might be a good choice because her friend loves reading, but buying a book can be expensive.
- The board game could be fun for them to enjoy together, but what if she already has the game you buy?
- A gift card gives her friend the option to choose what she wants to buy, but Manahil does not know her friend's likes or dislikes.
- The photo album would be a sentimental and thoughtful gift.
Step 4: Select the best idea
- Say who is going to do something about it, like, "Manahil will prepare a personalized photo album for her friend."
- Say how you are going to fix it. For example, "Manahil will collect photos of her friend and create a beautiful photo album."
- Say when you do it: "Manahil will start collecting the photos from today and must complete the album before her friend's birthday."
Step 5: Build and test the ideas
- Do what you decided. "Manahil starts collecting the photos of her friend from various sources such as friends and family and creates a beautiful photo album."
Step 6: Evaluate results
- Think if the plan worked, like, "Did Manahil's friend love the gift and feel touched by the memories captured in the album?"
- Decide if you need to change the plan or make a new one to fix the problem.
- If you are not happy with what happened, note this for the future and start again from step 2, pick a new plan, or change the old one.
Example 1: Dealing with bullying at school
Identify and define the problem: Aslam is being bullied at school and needs to find a way to handle the situation.
Explore information and ideas:
- Tell a grown up you trust such as a teacher, counselor, guardian or parent.
- Face the bully with courage and tell them to stop bothering you.
- Ask friends or classmates for support and help.
- Be part of groups at school that stop bullying.
Analyze the problem and evaluate alternatives:
- Telling a grown up for help and support can stop the bully.
- If you face the bully with courage, they might stop bullying you.
- Your friends can help you feel better and strong, but your friends may also start bullying you.
- Becoming part of anti-bullying groups may help you stop bullying, but it also diverts your attention from studies.
Select the best idea: Aslam decides to talk to his teacher about bullying.
Test the idea: He met with his teacher, explains the situation, and asks for help.
Evaluate results: Aslam receives support from the school, the bullying stops, and he feels safer and happier at school.
Remember: the idea Aslam finally selected was to tell a teacher. A child should never try to handle bullying alone — always involve a teacher or another trusted adult.
3.4 Problem Decomposition
Sometimes the problem is too large to solve all at once. Therefore, we decompose or divide problems into smaller sub problems. This technique is known as Problem decomposition. The decomposition of any problem can be done by dividing the problem into facts, input, outputs and instructions.
3.4.1 Facts
Facts are things we know that are true or real. They are like the building blocks of problem-solving process. For example, if we are baking bread, some facts could be that we need flour, yeast, oil, warm water, and salt.
3.4.2 Input
Inputs are the things we start with, like the ingredients for our bread (if that is the problem).
3.4.3 Output
Outputs are the cool things we get at the end, like fresh yummy bread! They are what we make or get after we put everything together.
3.4.4 Instructions
We combine facts, inputs, and outputs to create a list of steps (instructions) that guide us in solving the problem. There could be two different types of instructions:
(I) Specific instructions give clear, detailed steps on how to do something. For example, imagine you are baking a cake, a specific instruction would be: "Bake the cake for 40 minutes at 200 degrees Celsius."
(II) Non-specific instructions are more general and less detailed. In the cake baking scenario, a non-specific instruction would be: "Mix all the ingredients then cover it and let it sit."
Example 1: Building a LEGO castle
- Facts: we need LEGO bricks of different colors and sizes and maybe some special pieces like windows and doors.
- Input: A blank canvas or an empty space where we want to build the castle.
- Output: How we like our castle to look like, say we want a tall castle with towers, windows, a big gate, and maybe even a drawbridge.
Pulling it together (Instructions):
- We have LEGO bricks of different colors and sizes.
- We start with an empty space or a blank canvas.
- We want a castle with towers, windows, a gate, and a drawbridge.
3.5 Algorithmic Thinking
Algorithmic thinking is a way of solving problems by producing algorithms. It is a method for solving problems based on a clear definition of the steps; logically and repeatedly.
3.5.1 Algorithm
- An algorithm is an ordered clear sequence of steps to solve a problem or accomplish a task.
- An algorithm is a plan that tells you how to do a task.
We use algorithms all the time. For example, consider the steps that you take to:
- Prepare a pancake mix.
- Make a cup of tea.
- Convert temperature readings from Celsius to Fahrenheit.
To develop an algorithm, we need to represent the instructions in some way that is understandable to a person who is trying to figure out the steps involved. Two commonly used representations for an algorithm are pseudocode and flow charts.
3.5.2 Pseudocode
Pseudocode is a description of algorithms using everyday language, similar to English, but structured to resemble a simplified programming language.
Consider the example of adding two numbers. This algorithm performs addition of two numbers. The variable A and B will store the two numbers, while the variable Sum stores the sum of these two variables.
- Step 1: Start
- Step 2: Input two numbers A and B
- Step 3: Sum = A + B
- Step 4: Print the value of Sum
- Step 5: Stop
3.5.3 Flowchart
Flowcharts are diagrammatic representations that show a sequence of actions and the order in which they occur. For example, consider the example of adding two numbers:
3.5.4 Symbols used in Flow Charts
The following shapes and symbols are used in flowcharts:
| Symbol | Name | Used for |
|---|---|---|
| Oval | Start / End | To show the beginning and the end of a flowchart |
| Rectangle | Process | To show an action or a step that is done |
| Diamond | Decision | To show a question where a choice must be made, such as "Is it even?" |
| Parallelogram | Input / Output | To show input or output operations, such as "Input A, B" or "Print Sum" |
| Arrow | Flow line | To indicate the direction in which the process flows from one step to the next |
3.5.5 Guidelines for developing flowcharts
- Flowcharts can only have one start and one stop symbol.
- The general flow of processes (arrows) is top to bottom or left to right.
- Arrows should not cross each other.
- In case of loops, the flow of process could be from bottom to top.
Example: Calculating the cube of a given number
This algorithm takes a number as input from the user and then calculates its cube. The variable number stores the input number, and the cube stores the cube value calculated in the algorithm.
- Step 1: Start
- Step 2: Input number
- Step 3: Compute cube using formula: cube = number × number × number
- Step 4: Print cube
- Step 5: Stop
3.5.6 Algorithm building blocks
An algorithm is made up of three building blocks.
(I) Sequencing: The process must be executed in the same written order. (See previous examples.)
(II) Selection / Conditional: The process executes different sets of steps based on a conditional statement. Steps are executed if the condition is true, otherwise the next step is executed. For example, determining the largest number among all the entered numbers.
Pseudocode for finding the largest number between two given numbers. This algorithm will print the largest number between the two numbers entered by the user. The variables A and B store the given numbers.
- Step 1: Start
- Step 2: Read the Integer A
- Step 3: Read Integer B
- Step 4: If B is greater than A, then print B, else print A
- Step 5: Stop
(III) Repetitive / Iterative: Repetitive flow, also referred to as iterative flow, is a process in which a statement or a set of statements is executed repeatedly till a certain condition remains true.
For example, print "Hello World" five times. Here, we want to print the same sentence repeatedly, therefore iterative / repetitive process will be used here. A counter variable is needed to keep track of the repetition.
Pseudocode for printing Hello World on screen five times. This algorithm will print a simple message such as "Hello World" five times. The variable count acts as the counter variable.
- Step 1: Start
- Step 2: Initialize count = 1
- Step 3: Print "Hello World"
- Step 4: Add 1 to the count variable
- Step 5: Is count <= 5?
- Step 6: If Yes then Goto Step 2, else Goto Step 7
- Step 7: Stop
Summary
- Problems are like challenges that make our brain grow stronger.
- Simple problems are like small puzzles waiting to be solved.
- Complex problems are like big adventures that need more steps to solve.
- Decomposing a problem helps us understand the problem better.
- When solving problems, first, we think about what we know (our facts), like ingredients of a recipe.
- Next, we look at what we start with (our inputs), like the tools for making a craft.
- Then, we imagine what we want in the end (our output), such as a finished drawing or solved puzzle.
- When faced with a problem, we need a plan to solve the problem known as an algorithm.
- Algorithms are step by step recipes for solving problems.
- Algorithmic thinking is like having the superpower to solve problems.
- Flow charts are like a visual map showing the steps of an algorithm.
- Flowcharts use symbols and arrows to guide us through the process.
- Pseudocode is a simple way to write down algorithms using everyday language, just like writing a recipe in words before making a dish.
Important Terms — Book Vocabulary
📚 Book Vocabulary
| English | Meaning |
|---|---|
| Problem ⭐ | A problem is something (event, task, situation) that needs to be solved. It is like a puzzle or question for which a solution must be found. |
| Problem solving ⭐ | The process of finding solutions to challenges or puzzles using logical thinking and creativity. |
| Problem decomposition ⭐ | A problem-solving methodology that involves breaking down large problems into smaller, more manageable parts. |
| Iteration ⭐ | Iteration in algorithms refers to the repetition of a process or set of instructions until a certain condition is met or a desired result is achieved. |
| Condition ⭐ | A condition in algorithms is a logical statement or expression that determines the execution or repetition of certain instructions based on whether it evaluates to true or false. |
Extra Help Words
🌱 Extra Help Words
| English | Meaning |
|---|---|
| Sequence | Steps written and followed one after another, in order. |
| Selection | Choosing between two paths in an algorithm by checking a condition. |
| Variable | A named store that holds a value which can change, such as A, B, Sum or count. |
| Counter | A variable used to count how many times a loop has repeated. |
| Sub-problem | One smaller part of a big problem, made by breaking the problem down. |
| Instruction | A single step that tells what to do. |
Exercise 1 — Encircle the correct answer
1(i) The problem is a:
The problem is a: (a) Toy (b) Challenge waiting to be solved (c) Storybook (d) Game
Answer: (b) Challenge waiting to be solved
Explanation: A problem is something that needs to be solved — a challenge or puzzle waiting for a solution. A toy, a storybook or a game is not, by itself, a problem.
1(ii) The example of a simple problem is:
The example of a simple problem is: (a) Building a robot (b) Tying your shoes (c) Creating a video game (d) Baking a cake
Answer: (d) Baking a cake
Explanation: This book itself gives "bake a cake or cook instant noodles" as its example of a simple problem in 3.2.1 (printed p88), because it is solved by simply following a recipe. Tying your shoes is also a simple task in everyday life, but the answer taken from this book's own example is (d). Building a robot or creating a video game needs many steps and skills, so those are complex problems.
1(iii) To create a problem-solving plan, we need:
To create a problem-solving plan, we need: (a) Ingredients (b) Facts, Inputs, Outputs (c) Tools (d) details
Answer: (b) Facts, Inputs, Outputs
Explanation: In 3.4, a problem is decomposed into facts, input, outputs and instructions, and a plan is built from these. Note that the book's own 3.4 also lists instructions among the parts of a problem; among the four choices given here, (b) is the only correct one. Ingredients and tools belong to particular examples, such as baking.
1(iv) Decomposing a problem means:
Decomposing a problem means: (a) Making it bigger (b) Breaking it into smaller parts (c) Solving it quickly (d) Ignoring it
Answer: (b) Breaking it into smaller parts
Explanation: Problem decomposition means dividing a large problem into smaller sub-problems so that each part is easier to understand and solve.
1(v) Algorithmic thinking is like:
Algorithmic thinking is like: (a) Being a detective solving a mystery (b) Being lost in a maze (c) Watching TV (d) Playing video games
Answer: (a) Being a detective solving a mystery
Explanation: Algorithmic thinking means examining a problem carefully, looking for clues and following clear steps to reach a solution — just like a detective solving a mystery. The summary also calls it "having the superpower to solve problems".
Exercise 2 — Fill in the blanks
2(i) Simple problems are like ____ puzzles
Simple problems are like __________ puzzles. (Word bank: Plan, language, part, small, process)
Answer: small
Explanation: The summary says: "Simple problems are like small puzzles waiting to be solved."
2(ii) Decomposing a problem helps us understand each ____ better
Decomposing a problem helps us understand each __________ better. (Word bank: Plan, language, part, small, process)
Answer: part
Explanation: When a problem is broken down, each smaller part can be understood and solved on its own.
2(iii) An algorithm is a step-by-step ____ for solving a problem
An algorithm is a step-by-step __________ for solving a problem. (Word bank: Plan, language, part, small, process)
Answer: Plan
Explanation: An algorithm is a plan that tells you how to do a task, written as an ordered sequence of steps.
2(iv) Pseudocode is a simple way to write down algorithms using everyday ____
Pseudo code is a simple way to write down algorithms using every day __________. (Word bank: Plan, language, part, small, process)
Answer: language
Explanation: Pseudocode uses everyday language, similar to English, structured like a simplified programming language.
2(v) Flow charts use symbols and arrows to guide us through a ____
Flow charts use symbols and arrows to guide us through a __________. (Word bank: Plan, language, part, small, process)
Answer: process
Explanation: The arrows in a flowchart show the direction in which the process flows from one step to the next.
Exercise 3 — Descriptive questions
3(i) An example of a simple problem and how it was solved
Give an example of a simple problem you've faced and how you solved it.
Answer: Example answer: The simple problem was that I had to make a cup of tea for my grandmother, and I did not want to forget any step.
I solved it by following a fixed order of steps, like a recipe: boil water in a kettle, put a tea bag in the cup, pour the boiled water into the cup, leave the tea for 3 to 5 minutes, then add milk and serve. Because the steps were clear and in order, the problem was solved without any difficulty.
Explanation: Any everyday example with a clear question and basic steps is acceptable — for example cooking instant noodles, tying shoelaces or packing a school bag. The important point is that a simple problem is solved by following a few clear steps, and no special expertise is required.
3(ii) Why break a problem into smaller parts?
Why is it important to break down a problem into smaller parts?
Answer: A large problem can be too big and confusing to solve all at once. Breaking it into smaller parts makes each part easy to understand, easy to solve and easy to check. Small mistakes can be found and fixed in one part without disturbing the whole solution, and the solved parts can then be joined together to solve the whole problem.
Explanation: This is problem decomposition. The book's LEGO castle example shows the same idea: facts, input and output are separated first, and only then are the instructions pulled together.
3(iii) Benefits of the step-by-step process of problem solving
List down the benefits of step-by-step process of problem solving.
Answer: The benefits of the step-by-step process are:
1. Nothing important is forgotten, because every step is written in order. 2. The problem becomes clear, so the solver knows exactly what to do next. 3. Mistakes can be found at the exact step where they happened. 4. The same steps can be repeated to solve a similar problem again. 5. Other people can follow, understand and check the solution. 6. Big problems become manageable when they are handled one step at a time.
Explanation: The six-step guide in this unit (identify, explore, analyze, select, build and test, evaluate) is itself a step-by-step process, and evaluating the results at the end shows whether the plan worked or must be changed.
3(iv) A real-life situation where you might use an algorithm
Can you think of a real-life situation where you might use an algorithm, like a step-by-step plan?
Answer: Example answer: Getting ready for school in the morning works like an algorithm: Step 1: Wake up. Step 2: Brush teeth and wash face. Step 3: Wear the uniform. Step 4: Eat breakfast. Step 5: Pack the school bag. Step 6: Leave for school. If the steps are followed in the same order every day, nothing is missed.
Explanation: Recipes, instructions for assembling furniture and following a route on a map are also algorithms, as the Note for Teachers in this book points out. An algorithm is simply an ordered, clear sequence of steps.
3(v) How planning a solution reduces the risk of failure
How does planning a solution reduce the risk of failure?
Answer: Planning shows the whole path before we start, so weak points and missing things can be seen in advance. A plan lets us compare different ideas and select the best one instead of guessing. While following the plan, each step can be tested; if a step fails, only that step needs to be changed. Finally, evaluating the results tells us what to improve next time. Because of this, there are fewer surprises and the chance of complete failure becomes much smaller.
Explanation: This is exactly why the six-step approach includes "build and test" and "evaluate results" as separate steps: testing catches problems early, and evaluation stops the same mistake from being repeated.
Exercise 4 — Class Activities
4(i) Ali's headache — the six-step solution
Solve the given scenario by following the six step problem solving guideline: "Ali is having severe headache. He must consult a doctor for treatment."
Step 1 — Identify the problem: Ali is having a severe headache and needs proper treatment.
Step 2 — Explore information and ideas: rest in a quiet room; drink water; take a rest and avoid screen time; tell a parent or elder; consult a doctor.
Step 3 — Analyze the problem and evaluate alternatives: rest and water may help a mild headache, but a severe headache can be a sign of illness, so home ideas alone are risky.
Step 4 — Select the best idea: consult a doctor for treatment, as the scenario states, with the help of a parent or elder.
Step 5 — Build and test the idea: Ali tells his parent, visits the doctor, explains the problem, and takes the medicine and advice the doctor gives.
Step 6 — Evaluate results: check whether the headache is gone and Ali feels better. If it continues, go back to the doctor instead of trying random remedies.
Answer: Following the six steps, Ali identifies the severe headache as the problem, considers the possible ideas, selects the safest one — consulting a doctor — acts on it with an elder's help, and then checks the result.
Explanation: The scenario already names its solution (consult a doctor); the six steps show how Ali reaches and carries out that solution safely. A child with a severe headache should always involve a parent, elder or doctor — never take medicine on his or her own.
4(ii) Grocery shopping — problem decomposition
Apply the concept of problem decomposition and write down the sub-problems for the following scenario: "Your mother asks you for grocery shopping and you need to go to the grocery shop." The problem identified here is "How to do grocery shopping".
Facts: the names and quantities of the items mother needs; the money available; the shop's location and opening time.
Input: the shopping list and the money given by mother.
Output: all the listed items bought correctly, with the bill and any remaining change brought home.
Answer: Sub-problems (smaller parts of "How to do grocery shopping"):
1. Prepare the list: write down each item and its quantity. 2. Take the money: count the money and keep it safely. 3. Reach the shop: choose the safe route and go to the grocery shop. 4. Find the items: pick each item from the shelves and check its quality and price. 5. Check the list: tick off every item so nothing is forgotten. 6. Pay the bill: pay, count the change and take the receipt. 7. Return home safely and hand over the items, bill and change.
Explanation: Each sub-problem is small and easy to solve on its own. Solving all of them in order solves the whole problem — this is problem decomposition. (The book prints "You mother" in this activity; it should be "Your mother".)
4(iii) Algorithm: table of a number up to 10
Write an algorithm that allows the person to enter a number, algorithm will print table of that number up to 10.
Step 1: Start
Step 2: Input the number, call it n
Step 3: Set i = 1
Step 4: Print n × i = (n × i)
Step 5: Add 1 to i
Step 6: If i <= 10, go back to Step 4
Step 7: Stop
Check with n = 3: the algorithm prints 3 × 1 = 3, 3 × 2 = 6, 3 × 3 = 9, and so on up to 3 × 10 = 30 — exactly ten lines, then it stops.
Answer: The algorithm above uses repetition: the print step repeats while i is not more than 10.
Explanation: A counter (i) keeps track of the repetition. The loop must go back to the Print step only — not to "i = 1" — otherwise the table would start again and again and never finish. Compare the Textbook note on the "Hello World" pseudocode in the Lesson.
4(iv) Algorithm: pass or fail from four subjects' percentage
Write an algorithm that determines whether a student has passed the exam or not. The algorithm takes grades of four subjects as input and then the algorithm calculates the percentage obtained by the student. If the percentage of marks obtained by the student is greater than 60 % then the student has passed the exam otherwise student has failed the exam. Hint: Simple decision making is needed to solve this problem.
Assumption (the book does not state maximum marks): each of the four subjects is out of 100 marks, so the total is out of 400.
Step 1: Start
Step 2: Input the marks of the four subjects
Step 3: total = marks1 + marks2 + marks3 + marks4
Step 4: percentage = total ÷ 400 × 100
Step 5: If percentage > 60, Print "Pass", else Print "Fail"
Step 6: Stop
Example 1: marks 70, 65, 80, 75 → total = 290 → percentage = 72.5 → 72.5 > 60, so Pass.
Example 2: marks 60, 60, 60, 60 → total = 240 → percentage = 60 → 60 is NOT greater than 60, so Fail under the printed rule.
Answer: The algorithm calculates the percentage of four subjects and prints "Pass" only when the percentage is greater than 60; otherwise it prints "Fail".
Explanation: Read the condition exactly as the book prints it: "greater than 60 %" is a strict test. A student with exactly 60% does NOT pass under this wording, because 60 is not greater than 60. Do not change the rule to "60 or more" — that would be a different algorithm. (In the book's sentence, "than the student has passed" is a misprint for "then the student has passed".)
4(v) Algorithm: sum of the first 5 numbers
Write an algorithm that calculates the sum of the first 5 numbers i.e. the sum of 1, 2, 3, 4 and 5. Hint: Repetitive/iterative flow statements are needed to solve this problem.
Step 1: Start
Step 2: Set sum = 0 and i = 1
Step 3: sum = sum + i
Step 4: Add 1 to i
Step 5: If i <= 5, go back to Step 3
Step 6: Print sum
Step 7: Stop
Working: sum grows as 0 + 1 = 1, then 1 + 2 = 3, then 3 + 3 = 6, then 6 + 4 = 10, then 10 + 5 = 15. When i becomes 6, the condition i <= 5 is false, so the loop stops and prints 15.
Answer: The sum of the first 5 numbers is 15.
Explanation: This is iteration: the same two steps repeat while the condition i <= 5 remains true. The loop goes back to the adding step only; going back to Step 2 would reset sum and i and the loop would never end.
In-lesson Activities
Activity (p90) — Simple or complex?
Activity (printed p90): Teacher will present different problems and ask students if each one of the problems is simple or complex.
Answer: Model answers for the problems in this unit: Lost puppy in the park — complex (many possible actions, no single recipe). Broken favorite toy — complex (first we must find out what is broken). Aslam's coins (3 bags × 5 coins) — simple (one clear step: 3 × 5 = 15). Baking a cake / cooking instant noodles — simple (follow the recipe). Calculating the LCM — complex (several division steps). Deciding whether a number is prime — complex (checking many divisors). The book and pen money problem — complex (needs careful setting up before calculating).
Explanation: A problem is simple when it has a clear question and can be solved with basic steps or a recipe. It is complex when it has many steps or must first be broken into smaller problems.
Activity (p96) — A real-life problem and the six steps
Activity (printed p96): Watch and Learn — teacher gives an example of a real-life problem he/she has faced and discusses how he/she solved it. Hands-on Practice — each student thinks of a real-life problem he/she has faced and follows the six steps problem solving guidelines to prepare a solution of that problem.
Answer: Model answer (one example): Problem — I keep forgetting to bring my homework notebook to school.
Step 1 — Identify: I forget my homework notebook on most days. Step 2 — Explore ideas: pack the bag at night; keep the notebook always inside the bag; write a reminder note on the door; ask a family member to remind me. Step 3 — Analyze: packing at night is calm and reliable; a reminder note can be missed; asking others makes me dependent. Step 4 — Select: pack the school bag every night after dinner, with the notebook checked first. Step 5 — Build and test: follow the routine for one week. Step 6 — Evaluate: I forgot the notebook zero times in the week, so the plan worked; keep the routine.
Explanation: Any real-life problem is acceptable if all six steps are followed in order and the last step honestly checks whether the plan worked.
Activity (p99) — Decomposing a complex problem
Activity (printed p99): Watch and Learn — teacher gives an example of a complex problem and demonstrates how it can be decomposed to find the solution. Hands-On-Practice — each student identifies a complex problem he/she has faced and prepares a solution of this problem by decomposing the problem.
Answer: Model answer: Complex problem — preparing breakfast for the family.
Facts: what food is available at home; how many people will eat; how much time is available. Input: the ingredients and utensils we start with. Output: a ready, served breakfast. Instructions (the decomposed sub-problems): 1. Decide the menu. 2. Take out the ingredients. 3. Prepare each item one by one (boil water, make tea, cook eggs, toast bread). 4. Set the table. 5. Serve the breakfast. Each sub-problem is small and simple, and together they solve the whole problem.
Explanation: Decomposition works when the sub-problems are smaller than the original problem and, solved in order, they complete it — the same pattern as the LEGO castle example in the Lesson.
Activity (p105) — Design pseudocode and flowcharts
Activity (printed p105): Teacher will engage the students to practice creating pseudocode and flowcharts for various problems: 1. Getting ready for school. 2. Planting a flower in the pot. 3. Determine if the given number is even or odd. 4. Find sum and average of three numbers. 5. Multiply any two given numbers. 6. Take a number from the user; print Car if the number is 1, otherwise print Bus.
1. Getting ready for school — Step 1: Start. Step 2: Wake up. Step 3: Brush teeth and wash face. Step 4: Wear uniform. Step 5: Eat breakfast. Step 6: Pack school bag. Step 7: Stop. (Pure sequence.)
2. Planting a flower in a pot — Step 1: Start. Step 2: Fill the pot with soil. Step 3: Make a small hole in the soil. Step 4: Place the seed or plant in the hole. Step 5: Cover with soil. Step 6: Water the plant. Step 7: Stop. (Pure sequence.)
3. Even or odd — Step 1: Start. Step 2: Input a number. Step 3: Divide the number by 2 and check the remainder. Step 4: If the remainder is 0, Print "Even", else Print "Odd". Step 5: Stop. (Selection.)
4. Sum and average of three numbers — Step 1: Start. Step 2: Input three numbers A, B, C. Step 3: Sum = A + B + C. Step 4: Average = Sum ÷ 3. Step 5: Print Sum and Average. Step 6: Stop. (Sequence.)
5. Multiply two numbers — Step 1: Start. Step 2: Input two numbers A and B. Step 3: Product = A × B. Step 4: Print Product. Step 5: Stop. (Sequence.)
6. Car or Bus — Step 1: Start. Step 2: Input a number. Step 3: If the number is 1, Print "Car", else Print "Bus". Step 4: Stop. (Selection.)
Answer: Model pseudocode for all six design tasks is given in the working above; a flowchart for each task uses the same steps with the symbols learned in 3.5.4.
Explanation: Tasks 1, 2, 4 and 5 are pure sequences; tasks 3 and 6 need a decision (selection). The book prints task 3 as "even or add" — "add" is a misprint for "odd", and task 6 as "take a number for user", which means "take a number from the user".
Practice is organized in complete sets of 10 questions. Practice Set 1 can be attempted by everyone. Sets 2–5 are Pro sets. Question order and option order are shuffled on every new attempt; after you check an answer it locks, and the correct answer and explanation appear beneath it.
Practice Set 1
What makes a problem a SIMPLE problem?
Explanation: Simple problems are like puzzles that are easy to solve. They usually have a clear question with an answer that you can find using basic steps.
Which of these is a COMPLEX problem?
Explanation: A school timetable has many connected parts and needs a lot of thinking and planning, so it is complex. The other choices are single, easy tasks.
In the six-step problem-solving approach, which step comes immediately AFTER "Explore information and ideas"?
Explanation: The six steps run in order: identify the problem, explore information and ideas, then analyse the problem and evaluate alternatives, before selecting, building and evaluating.
After the class play is over, the teacher asks the students: "Did our plan work? What should we change next time?" Which step of problem solving is this?
Explanation: Looking back at whether the plan worked, and deciding what to change, is the last step: evaluate results.
For the problem "make a poster for the classroom wall", which of these are the INPUTS?
Explanation: Inputs are the things we start with. The finished poster is the output, and the written steps are the instructions.
Which of these is a SPECIFIC instruction?
Explanation: A specific instruction gives clear, detailed steps — exactly what to do and for how long. The others are general and leave the details unclear.
Which way of representing an algorithm uses shapes and arrows?
Explanation: A flowchart is a diagrammatic representation: it uses shapes for the steps and arrows to show the order in which they happen. Pseudocode uses words instead.
Read this pseudocode: Step 1: Start. Step 2: N = 5. Step 3: N = N + 3. Step 4: Print N. Step 5: Stop. What is printed?
Explanation: N starts as 5. Step 3 replaces it with 5 + 3 = 8, so the value printed is 8.
In a flowchart, the DIAMOND shape is used for:
Explanation: Diamonds indicate decisions that need to be made. Think of a diamond as a question, with different ways out depending on the answer.
A flowchart goes: Start → "Read R" → "S = R × R" → "Print S" → Stop. If R is 4, what is printed?
Explanation: The chart is a straight sequence: S = R × R = 4 × 4 = 16. (64 would be the cube, R × R × R, which this chart does not compute.)
100MCQs ProComing soon
Practice Set 2 with Pro
Rs. 250/month
10 more original practice questions on this unit’s topics, with full explanations — available with Pro when accounts open.
Pro accounts are not open yet. Lessons, solved exercises and teacher’s guides on 100MCQs are always free.
- Everything in Free
- Full access to approved practice MCQs
- Exclusive practice questions
- Complete eligible practice sets — more opportunities to practise
100MCQs ProComing soon
Practice Set 3 with Pro
Rs. 250/month
10 more original practice questions on this unit’s topics, with full explanations — available with Pro when accounts open.
Pro accounts are not open yet. Lessons, solved exercises and teacher’s guides on 100MCQs are always free.
100MCQs ProComing soon
Practice Set 4 with Pro
Rs. 250/month
10 more original practice questions on this unit’s topics, with full explanations — available with Pro when accounts open.
Pro accounts are not open yet. Lessons, solved exercises and teacher’s guides on 100MCQs are always free.
100MCQs ProComing soon
Practice Set 5 with Pro
Rs. 250/month
10 more original practice questions on this unit’s topics, with full explanations — available with Pro when accounts open.
Pro accounts are not open yet. Lessons, solved exercises and teacher’s guides on 100MCQs are always free.
Teacher's Guide — Unit 3: Algorithmic Thinking and Problem Solving
The textbook's Note for Teachers (printed p111)
The following guidance is the textbook's own Note for Teachers, reproduced for the teacher:
- Teachers must provide real-world problem-solving scenarios and challenge students to apply the techniques of problem solving they have learned.
- Teachers must explore practical applications of algorithmic thinking and problem-solving skills in various fields, such as computer science, engineering, mathematics, and everyday life.
- Engage students in discussions about the importance of breaking down complex problems into smaller, more manageable steps.
- Introduce the concept of algorithmic thinking. Explain that algorithms are step-by-step procedures used to solve problems.
- Use real-life examples to illustrate algorithms, such as recipes, instructions for assembling furniture, or navigating a route on a map.
- Use interactive demonstrations or group activities to reinforce these concepts.
- Teachers must teach students how to design algorithms by breaking down problems into smaller steps, identifying patterns, and developing clear and concise instructions.
- Guide students through the process of refining and improving their algorithms through testing and iteration.
How to teach the six steps
- Teach the steps in order and always with one running example — the birthday gift example (Manahil and Moomal) is ideal because every step has a concrete line in the book.
- Insist that Step 2 (explore) comes before judging ideas; children often jump straight to a solution. The book's own wording — write down all ideas, even ones that seem wrong — is the rule to repeat.
- In Step 3, make pupils say one good point and one weak point for each idea, as the book does for the book, board game, gift card and photo album.
- Step 6 is the step classes most often skip. Always ask: "Did the plan work? What would you change?" — and link it back to Step 2, as the book directs.
- For the headache activity (Exercise 4(i)), the scenario's own solution is "consult a doctor". Build the six steps around that outcome and stress that medicine is never taken without an elder or a doctor.
How to teach pseudocode and flowcharts
- Start from the adding-two-numbers pair (p100–p101): read the pseudocode aloud, then trace the same five boxes in the flowchart so pupils see they are the same algorithm in two representations.
- Teach the five symbols with the book's own examples (Oval — Start/End; Rectangle — action; Diamond — decision question; Parallelogram — Input/Print; Arrow — direction of flow) and the four guidelines in 3.5.5, especially one Start and one Stop.
- Trace every flowchart with a finger, following the arrows. For the largest-number chart, try A = 4, B = 9 (prints B) and A = 9, B = 4 (prints A) so both branches are walked.
- For the "Hello World" loop, trace count on paper: 1, 2, 3, 4, 5 prints, then count = 6 ends the loop. This trace is the clearest way to show why the loop-back must return to the Print box and not to "count = 1".
- Let pupils draw charts on the board or paper only — no software is needed for this unit, and no pupil work in this unit was produced or tested on real software.
Common misconceptions
- "A complex problem is just a hard sum." No — complexity is about many steps or needing decomposition, not about difficult arithmetic; the LCM example is complex because of its steps.
- "Instructions in a decomposition are the whole recipe." The book's LEGO "Pulling it together" list restates facts, input and output; point out that real instructions are action steps, and compare with the specific instruction "Bake the cake for 40 minutes at 200 degrees Celsius".
- "A loop that goes back to the start is fine." Show with the Hello World trace that returning to the initialisation step resets the counter and the loop never ends.
- "60% means pass." In Exercise 4(iv) the printed rule is strictly greater than 60%, so exactly 60% is a Fail in that algorithm. Teach pupils to read conditions exactly as written.
- "Friends can solve bullying." The book's analysis itself notes friends may not help; the selected solution in the book is telling a teacher. Reinforce this every time the example is discussed.
Textbook corrections and notes
- p105, Hello World pseudocode — printed Step 6 "If Yes then Goto Step 2" is defective: Step 2 re-initializes count = 1, so the loop would never terminate. Correct step: Goto Step 3. The flowchart on the same page is correct (loop returns to the Print box only). Visible Textbook note in the Lesson; the printed pseudocode is quoted unchanged.
- p103, cube pseudocode — "Step 3" is printed twice (Compute cube; Print cube), giving the sequence 1, 2, 3, 3, 4. Numbering slip only; the step order and the flowchart are correct. Visible Textbook note in the Lesson; steps shown with corrected numbering.
- p105, Activity item 3 — "even or add" is a misprint for "even or odd". Visible Textbook note in the Lesson and in the solved activity card.
- p89 — "breaking then into many simple problems": "then" is a misprint for "them". Corrected in the Lesson text.
- p89 — the book and pen example is ambiguous; the only reading consistent with the printed total (Rs 800) is book = twice the pen + Rs 500, giving pen Rs 100 and book Rs 700. No solution is printed in the book. Visible Textbook note in the Lesson.
- p107, Exercise 1(ii) — two options are defensible in everyday life (baking a cake; tying your shoes). The key follows the book's own example in 3.2.1 (p88): (d) Baking a cake. Explained openly in the solved card.
- p108, Exercise 1(iii) — the keyed option (b) "Facts, Inputs, Outputs" omits Instructions, although 3.4 (p96) divides a problem into facts, input, outputs and instructions. Option (b) remains the only plausible answer; the omission is noted in the solved card.
- p110, Exercise 4(iv) — the condition is strictly "greater than 60 %"; exactly 60% does not pass. The book does not state maximum marks, so the model solution states its assumption openly (100 per subject, 400 total). Also "than the student has passed" is a misprint for "then the student has passed".
- p109, Exercise 4(ii) — "You mother" is a misprint for "Your mother". Corrected in the solved card and noted there.
- p97, Figure 3.10 — the picture's Facts/Inputs include oatmeal and sunflower seeds, which are not in the written facts list of 3.4.1. Visible Textbook note in the Lesson.
- p90, Figure 3.3 — the LCM working for 10, 18 and 20 was independently checked and is CORRECT: LCM = 2 × 2 × 3 × 3 × 5 = 180. No correction needed.
- p88 — the coins example's answer is not printed in the book; 3 bags × 5 coins = 15 coins is supplied in the Lesson.
- Minor slips corrected silently in the Lesson text and recorded here: p87 SLO wording ("breakdown" as a verb; a question mark at the end of SLO 6); p91 "why it is problem" (missing "a"); p94 "Did Manahil's friend loves the gift" (grammar); p98 "may be" for "maybe" in the LEGO facts; p103 "based on a, conditional statement" (stray comma); p104 diamond text spacing "Is B >A"; p105 Activity item 6 "take a number for user" (means "from the user"); p106 summary grammar slips ("needed" for "need", "we look what we start with", "known as algorithm"). None of these changes any meaning, answer or step order.
Safeguarding — the bullying example
The bullying example (pp94–96) must always be taught as a help-seeking example: the solution the book selects is telling a teacher. Never suggest that a child should face a bully alone, and always tell pupils to involve a teacher, counselor, parent or another trusted adult immediately if they or a classmate are being bullied. If a pupil discloses real bullying during this lesson, follow the school's safeguarding procedure.
A note on evidence
All algorithms, pseudocode and flowcharts in this unit were traced and checked on paper against the printed book. No claim is made that students were tested on real software; this unit needs no computer or software at all.
