Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem Solving Logical reasoning or deductive reasoning.

Similar presentations


Presentation on theme: "Problem Solving Logical reasoning or deductive reasoning."— Presentation transcript:

1 Problem Solving Logical reasoning or deductive reasoning.
Using a set of facts to determine whether a new set of facts are true or false. Some problems to consider: There are two jugs. A and B. Jug A has a capacity of three litres. Jug B has a capacity of five litres. There are no markings on the jugs, so it is not possible to tell exactly how much is in a jug just by looking at it, unless it is full or empty. There is a sink with a water tap and a drain. How can exactly 4 litres of water be obtained from the tap using the jugs Step Jug A (3) Jug B (5) 1

2 Problem Solving Some problems to consider: Step Jug A (3) Jug B (5) 1
2 4 5 6 7 8

3 Problem Solving Some problems to consider:
2) The police are interrogating five suspects after a bank robbery. Each of them makes two statements, but it turns out only five of these statements are true. Can you work out who committed the crime? What strategy will you use to work it out? Alan said: It wasn’t Ben. It was Carl. Ben said: It wasn’t Alan. It was Dave. Carl said: It wasn’t Dave. It wasn’t Ben, either. Dave said: It wasn’t Eddie. It was Alan. Eddie said: It wasn’t Carl. It was Derek.

4 Problem Solving Some problems to consider:
3) You are in a room with 2 doors leading out. Behind 1 door is a coffer overflowing with jewels and gold, along with an exit. Behind the other door is an enormous, hungry lion that will pounce on anyone opening the door. You do not know which door leads to the treasure and exit, and which door leads to the lion. In the room you are in are 2 individuals. The first is a knight, who always tells the truth, and a knave, who always lies. Both of these individuals know what is behind each door. You do not know which individual is the knight, or which one is the knave. You may ask one of the individuals exactly 1 question. What should you ask in order to be certain that you will open the door with the coffer behind it, instead of the hungry lion?

5 2 Stages of Problem Solving Defining the problem.
A well defined problem has four components A clearly defined initial condition given. A clearly defined goal. A clearly defined set of resources and constraints. Ownership. For example: You are at a river that you want to cross with all your goods. Your goods consist of a chicken, a bag of grain and your dog, Rover. You have to cross the river in your rowing boat but can only take one passenger at a time – the chicken, the dog or the bag of grain. You can’t leave the chicken alone with the grain as the chicken will eat the grain. You can’t leave your dog alone with the chicken as Rover will eat the chicken. However you know that Rover does not eat grain. How do you get everything across the river intact 2

6 2 Stages of Problem Solving CAN YOU COME UP WITH A SOLUTION?
So lets break this problem down into its components Initial Situation You, the chicken, the bag of grain and the dog are on one bank of a river with access to a rowing boat. Resources The rowing boat and your knowledge and problem solving skill, Constraints You can only take one passenger, you must not leave Rover with the chicken or the chicken with the grain. Goal You, the chicken, the bag of grain and the dog on the opposite bank of river. Ownership You will be involved in planning the solution and carrying it out. CAN YOU COME UP WITH A SOLUTION? 2

7 2 Stages of Problem Solving Puzzle: Lateral Thinking.
Some problems don’t give you all the facts and you have to Use lateral thinking to establish some more. Puzzle: Six glasses are arranged in a line. The first three are filled with water, the second three are empty. You are allowed to move only a single glass. In one move can you achieve an ordering of the glasses which alternates full and empty glasses along the line? What constraint or boundaries did you assume? A man lives on the 18th floor of a tower block. Every weekday morning he takes the lift to the ground floor and walks to work. Every weekday evening, he walks from work, takes the lift to the 12th floor and then takes the stairs to the 18th floor. If it was raining in the morning, he takes the lift straight to the 18th floor in the evening. Why? In all problems challenge your assumptions! 2

8 Problem Solving Strategies for problem solving Exhaustive search
You are to fill a square with 9 numbers. Each Row, column and diagonal needs to add up to the same value. This is a specific instance (0-9 & 3X3) of a general problem (N-N & NXN) How would you solve this problem?

9 Problem Solving Strategies for problem solving Exhaustive search
One method is to use an EXHAUSTIVE SEARCH = which simply means trying ever possible combination until you get it. This would work out as 9*8*7*6*5*4*3*2*1 which = 362,880 possible ways of filling the square or 9! Size of the problem – 5X5 = 25! = 1.55 * 1025 possible ways of filling the square.

10 Problem Solving Strategies for problem solving Exhaustive search
Needs a better algorithm What if we knew that the middle number has to be 5 and each 3 numbers had to add up to 15 – would be easier.

11 Problem Solving Strategies for problem solving
2) Divide and conquer or binary search Ask a friend to think of a number between 1 and You have a guess and your friend tells you whether it is correct, too low or too high. What is the maximum number of guesses you will need with this form of search method? How many guess between 1 and 2N How many guesses would this take using an exhaustive search?

12 This is where developing good algorithms come in.
Problem Solving Strategies for problem solving 3) A flash of insight. You have a bag of 8 coins which all look identical, but one of them is counterfeit and weighs less than a genuine coin. You have a two-pan balance, but no weights. What is the maximum number of weighing's needed to identify the fake coin? The trick is to think of a method that reduces the need of using an exhaustive search. This is where developing good algorithms come in.

13 Abstraction The process of reducing a problem to their essential features. Finding similarities or common aspects about a problem and ignoring the differences. View from a high level – ignoring the detail. We use abstractions every day

14 Abstraction Two types of abstraction Representational Abstraction
Generalisation/Categorisation

15 Abstraction – Representational
Process of removing unnecessary details until it is possible to represent the problem in a way that can be solved. Looking more at the big picture. See previous slide with the London Underground Useful for someone travelling around London. Is it useful for an engineer wanting to build a new Line in the underground? Sat Nav Example: Identify point A and point B in someway Identify the connecting paths between A and B Calculate the shortest path between A and B. Remove irrelevant information such as rivers, railways, landmarks etc.

16 Abstraction –Generalisation / Catergorisation
Placing aspects of problem into broader categories to arrive at a Hierarchical representation Used in Object orientated programming. Vehicles Car Bus Lorry Van

17 Information Hiding Ties in with abstraction – The removing or all irrelevant details from a problem. For example – the Bridge problem years ago in the old Prussian city of Koingsberg. It had seven bridges and the inhabitants likes to stroll around the city on a Sunday afternoon, making sure to cross every bridge at least once. Nobody could figure out how to cross each bridge once and once only. Leonhard Eular used Information hiding to solve this problem.

18 Information Hiding The map of the city with the bridges.

19 Information Hiding Remove all irrelevant details from the map to come up with an abstraction

20 Information Hiding Create a graph with vertices and edges to represent the bridges and islands Euler concluded that each node needs to have an even number of connections to enter and leave in order for each bridge to be crossed once – therefore the above is impossible. Set a foundation to solve similar problems. North Bank West Island East Island South Bank

21 Abstraction – Procedural Abstraction
The concept that all solutions can be broken down into a series of sub problems. How programs written in code work. Design stage – sufficient to state what each procedure does not how it does it. Values are hidden from each procedure. Amendments can be isolated and changes made easily without affecting the whole solution. Procedure for Drawing Street Hides detail from Depends on Procedure for drawing house Hides detail from Depends on Procedures for drawing shapes.

22 Abstraction – Functional Abstraction
Similar to Procedural Abstraction The use of common functions to solve problems – generic across many problems. Also can be the actual application of the procedures mentioned last slide - in a coding language. The methods and data of the function are hidden from the user. e.g. Console.WriteLine() Console.ReadLine()

23 Abstraction – Data Abstraction
Process of organising and structuring data in a way that is useful to the programmer but how it is actually represented in the computer is hidden. Data types such as integers and strings have some abstraction to them. Higher level data abstractions such as queues, stacks, linked lists, trees etc. The hiding away of their representation allows you to build new data types fairly easy – such as stacks from arrays – or records from a number of data types. A separation of the actual implementation from the interface or use.

24 Abstraction – Problem Abstraction
Removing details until the problem is represented in a way that is possible to solve. How many moves would it take to swap the knights around.

25 1 2 3 4 5 6 7 8 9 Abstraction – Problem Abstraction Number the board
How many moves would it take to swap the knights around.

26 Abstraction – Problem Abstraction
Create a graph joining up the numbers that are connected. 5 Has been removed. 2 1 3 How many moves would it take to swap the knights around. 4 6 7 9 8

27 Abstraction – Problem Abstraction
Create a graph joining up the numbers that are connected. 5 Has been removed. 1 6 8 Now it is a bit easier to visualise a solution to this problem. 7 3 2 4 9

28 Decomposition / Composition
Breaking down large complex tasks or processes down into smaller more manageable tasks. Abstraction techniques are applied in this process. Procedural Composition – Process of creating a working system from the abstraction: Writing all the procedures and linking them together to create compound procedures Creating data structures and combining them to form compound structures.

29 Decomposition / Composition
A Sat Nav System Sat Nav System Journey Start Point End Point Travel Input travel data Input travel updates Road Network National Roads International Roads Calculate Route

30 Automation Process of creating computer models of real-life situations and putting them into action. Creates elegant solutions to difficult problems Understand the problem Begin able to create suitable algorithms Building up the algorithms into program code Using appropriate data in order to solve the problem. Example – Traffic light system A specification needs to consider: Location of all traffic lights The number of roads that meet at each set of traffic lights How many lanes of traffic are at each set of lights How much traffic there is on each of the lanes What time of day it is. Do they control a pedestrian crossing as well. Reviews of the system in play may required the rewriting of algorithms


Download ppt "Problem Solving Logical reasoning or deductive reasoning."

Similar presentations


Ads by Google