🎯 Learning Objectives
Develop the Algorithms, Programming and Development Learning Strands:
- Develop problem solving skills by decomposition
- Learn how to represent algorithms using flowcharts
- Learn how to represent algorithms using pseudo-code
- Understand how abstraction can help solving complex problems
- Develop further understanding that programming bridges the gap between algorithmic solutions and computers
💬 Key Vocabulary
- decomposition
- algorithms
- flowcharts
- pseudo-code
- abstraction
- selection
📝 Decomposition
- Sometimes, the problem is complex or seemingly complex. A common approach to solve a complex problem is to break down the problem into smaller, easier to solve problems. After we solved each of those smaller problems, the complex problem is solved.
- The above approach to problem solving is called divide-and-conquer.
- In computer science, to breaking down a problem into smaller, easier to solve problems is called decomposition.
- Let’s try decomposition on the following not so complex problem:
Write a program such that when a user inputs a number, the program will output it is an even or an odd number.
- To break down the above problem, we are going to use flowchart to help us.
- Flowcharts are very useful in visualising how algorithms work.
📝 Algorithms with Flowcharts
- A flowchart is a type of diagram that represents an algorithm, workflow or process, showing the steps as boxes of various kinds, and their order by connecting them with arrows.
- Each shape represent some steps in the algorithm:
- The following is a simple example of using flowchart to describe the steps to a simple problem of determining if an user’s input numbers are odd or not.
- The above problem has been decomposed into three parts:
- a user input a number
- determine if the number is even or odd
- output the appropriate message depending on the above step
Try It
Write a computer game that allows a user to guess the number that is picked by a computer. If the user guessed the number, the user is declared a winner. If the user guessed incorrectly, the computer will tell the user if the guess is too high or two low.
- Try your decomposition skill with the above problem.
- The first few steps have been started for you:
- computer pick a number
- a user input a number
🥈 Silver Badge
- Finish decomposing the problem by finishing all steps required to reach a solution.
- Create a flowchart using appropriate symbols for your steps.
- Upload both your steps and flowchart to www.bournetolearn.com.
📝 Solving a real life problem with flowchart
- Launch the application Flowol, click on File->New and you should see something like the following:
- Select the
lighthouse mimic
by clicking on it - The scenario or mimic has one input:the Sun and three outputs: Lamp, Lights and Foghorn
Try It
- Flowol is simple to use once you know it
- See if you can work out how to create a flowchart as shown below:
- If you get stuck, ask your teacher to show you.
🥇 Gold Badge
- The above flowchart will make the three outputs flash on and off every two seconds.
- Your task is to create a flowchart so that:
- when the Sun is down(off), all the three outputs will flash
- when the Sun is up (on), all the outputs should be off.
- Test your flowchart by clicking on the Sun to turn it on and off.
- Screenshot your working flowchart and upload to Bourne to Learn.
🥉 Platinum Badge – Functions
- Now you are familiar with how the software Flowol works.
- The above mimic has all three outputs flash on and off.
- follow the steps shown in the image below to create a flash function:
- Once you have created a function, the side menu will now have Sub block for you to use the functions you have created.
- Modify your flowchart from the Gold badge task to use this function.
- Test your flowchart as you have done with your Gold badge and upload the screenshot of your working flowchart to Bourne to Learn.
In this lesson, you…
- Learnt how to use flowcharts to illustrate the flow of the problem solving process.
- Used decomposition to break a problem down into more manageable chunks.
Next lesson, you will…
- Continue to use Flowol to create flowcharts to follow a sequence in an algorithm.
🏅 Badge it
🥈 Silver Badge
- Finish decomposing the problem by finishing all steps required to reach a solution.
- Create a flowchart using appropriate symbols for your steps.
- Upload both your steps and flowchart to www.bournetolearn.com.
🥇 Gold Badge
- The above flowchart will make the three outputs flash on and off every two seconds.
- Your task is to create a flowchart so that:
- when the Sun is down(off), all the three outputs will flash
- when the Sun is up (on), all the outputs should be off.
- Test your flowchart by clicking on the Sun to turn it on and off.
- Screenshot your working flowchart and upload to Bourne to Learn.
🥉 Platinum Badge
- Upload a screenshot of your function code.