Download presentation
Presentation is loading. Please wait.
Published byOlivia Collins Modified over 8 years ago
1
AS Computer Studies Algorithms & Problem Solving 1 & 2
2
Starter You need to get from home to college. Write down the basic steps involved. Review in 2 minutes: 1.Wake up 2.Get up 3.Get ready 4.Eat breakfast 5.Catch bus 6.Arrive at college.
3
Objectives Know what is meant by the term algorithm. Be able to write a simple algorithm for logical problems. Understand the stages of problem solving. Look at how to fully understand the problem: defining a problem.
4
An Algorithm Sounds like a technical term. “A formal set of instructions that can be followed to perform a specific task, such as a mathematical formula or a set of instructions in a computer program.” A major part of computer science. The process of turning a problem into a set of broken down tasks & instructions which can then be turned into computer code to AUTOMATE the solution to the problem. A good algorithm breaks down a problem efficiently, can be read/followed and can be converted into a computer language. Takes plain English problems and puts them into clearly structured English.
5
Looking back at the starter: You need to get from home to college. DEFINING THE PROBLEM: A simple ineffective algorithm: 1.Wake up 2.Get up 3.Get ready 4.Eat breakfast 5.Catch bus 6.Arrive at college. Does this suitably describe the problem? Could you follow these instructions and be able to get to college? What does ‘get ready’ actually involve? Does the bus appear in your home? Home College
6
Algorithm Example This is our top layer of our Algorithm. It does not clearly show everything which is involved. It does break the problem down into small tasks. 1.Wake up 2.Get up 3.Get ready 4.Eat breakfast 5.Catch bus 6.Arrive at college. Let’s look at the problem broken down.problem broken down.
7
Algorithm Exercise: Time Required 10mins “Thomas requires a cup of milky tea with two sugars brought to him on a try in his living room, placing on the table. Everything needed is in the kitchen. Sugar and teabags are in jars on the worktop. Write a simple algorithm and then break it down into a detailed algorithm. HOMEWORK: Complete the “Additional Algorithms Sheet”Additional Algorithms Sheet
8
Stages of Problem Solving Understand the problem Define the problem Define boundaries Plan Solution Check the Solution
9
Understand a Problem You are given the problem. You visualise and understand what the actual problem is. You appreciate why it is a problem.
10
Defining the Problem This lets you fully understand exactly what the problem involves. Has many CLEARLY DEFINED parts: An initial situation A goal A set of resources A set of constraints (limitations) Stated ownership Let’s work through an example…
11
A Problem Defined You needs to cross a river in a canoe. With you, you have a bag of grain, a chicken, and a fox. You can only carry one of the three at a time. If you leave the grain and the chicken, the chicken will eat the grain. If you take the grain, the fox will eat the chicken. How does he successfully cross the river with his load? Initial Situation: There’s you, a chicken, a fox, grain all on a river bank, with access to a canoe. Resources: A canoe and your knowledge / understanding of what is needed. Constraints: You can only carry one passenger. Can’t leave grain with chicken. Can’t leave fox with chicken. Goal: You, the chicken, fox and grain are on the other side of the river. Ownership: You will be involved in the planning an solution. How would you solve this problem? SOLUTION: Take the chicken across, leaving it on the other side. Returns alone in the canoe and picks up the bag of grain. After bringing across the grain, takes the chicken back to the original side, dropping him off, and picking up the fox. After bringing the fox to the other side, and leaving it with the grain, return back to the original side, retrieving the chicken, and making your 3rd and final trip crossing the river. At no point was the fox left alone with the chicken, or the chicken with the grain.
12
Your Turn: 10mins You are in the dark, and on the floor there are six shoes of three colors, and a heap of twenty-four socks, black and brown. How many socks and shoes must you take into the light to be certain that you have a matching pair of socks and a matching pair of shoes? Initial Situation: Resources: Constraints: Goal: Ownership: SOLUTION (HIDE): Three socks and four shoes would guarantee that you would have a matching pair of each. Since there are only two colors of socks, it doesn't matter how many are in the heap, as long as you take at least three, you are certain to have two of the same. As for the shoes, you must pick four, because selecting only three could result in one shoe in each of the three colors!
13
Why bother defining a problem? The problem would not be fully understood. The solution would not fully meet the requirements. How would you divide the problem up? – When working in a team – different people will do different tasks to contribute to the solution. It is important to think LATERALLY to fully understand and define a problem (challenge assumptions and establish facts)
14
Defining Boundaries Establishing what can or cannot be done to solve a problem. A way of identifying limitations. These could be anything. – Time – Available equipment – Software Lateral thinking is needed to ensure only real constraints are identified. – Ask questions – Identify what assumptions you are making and separate them from facts. – Form new facts from the questions asked, adding them to originally given information from the problem.
15
Problem Definition: Task 1 “Romeo and Juliet are lying dead on the floor, surrounded by water and broken glass. What happened?” Define the problem. – An initial situation – A goal – A set of resources – A set of constraints (limitations) – Stated ownership Define the boundaries. – Ask questions – Obtain facts, not assumptions.
16
Problem Definition: Task 2 “A man lives on the 18 th floor of a tower block. Every weekday morning he takes the lift to the ground floor and walks to work. When he comes back, he takes the lift to the 12 th floor and walks up the remaining 6 floor to get back to his flat. Why does he not use the lift the 18 th floor every weekday evening?” Define the problem. – An initial situation – A goal – A set of resources – A set of constraints (limitations) – Stated ownership Define the boundaries. – Ask questions – Obtain facts, not assumptions.
17
Algorithm Exercises Complete the additional algorithms exercises. Consider the stages in problem solving. Understand the problem Define the problem Define boundaries Plan Solution Check the Solution
18
Objectives Review Know what is meant by the term algorithm. Be able to write a simple algorithm for logical problems. Understand the stages of problem solving. Look at how to fully understand the problem: defining a problem.
19
Plenary What is an algorithm? What are the stages in problem solving? Why is it important to clearly define a problem? Why is it important to think laterally?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.