Foundations of Problem Solving chapter 2 Dr Lahen Ouarbya.

Slides:



Advertisements
Similar presentations
Test process essentials Riitta Viitamäki,
Advertisements

Chapter 1 - VB 2008 by Schneider1 Chapter 1 - An Introduction to Computers and Problem Solving 1.1 An Introduction to Computers 1.2 Windows, Folders, and.
Chapter 1 An Overview of Computers and Programming Languages.
Chapter 2: Problem Solving
Programming Types of Testing.
S.T.A.I.R.. General problem solving strategy that can be applied to a range problems.
Software Failure: Reasons Incorrect, missing, impossible requirements * Requirement validation. Incorrect specification * Specification verification. Faulty.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2 - Problem Solving
Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
Programming Fundamentals (750113) Ch1. Problem Solving
Playing board for the game Crooked Rules
Chapter 1 Program Design
Chapter 3 Planning Your Solution
BPC.1 Basic Programming Concepts
SUCCESS IN ALGEBRA.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
Programming Logic and System Analysis
Copyright © 2001 by Wiley. All rights reserved. Chapter 1: Introduction to Programming and Visual Basic Computer Operations What is Programming? OOED Programming.
Problem Solving for Programming Session 3 Dealing with Sequence, Choice and Repetition.
Data Structures and Programming.  John Edgar2.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
An Introduction to Textual Programming
Learning Objectives Data and Information Six Basic Operations Computer Operations Programs and Programming What is Programming? Types of Languages Levels.
Simple Program Design Third Edition A Step-by-Step Approach
Programming Translators.
Output and User Interface Design
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Program Development Life Cycle (PDLC)
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: An Introduction to Programming Using Visual Basic 2012, All Rights ReservedAn Introduction.
Computer Programming TCP1224 Chapter 3 Completing the Problem-Solving Process and Getting Started with C++
Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.
By the end of this session you should be able to...
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
As Class Convenes l Find your team’s table and have a seat l Pick up Team’s Modeling Folder l Remove Chapter 1 Assignment l Place your Chapter 2 Assignment.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Developing an Algorithm
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Developing an Algorithm. Simple Program Design, Fourth Edition Chapter 3 2 Objectives In this chapter you will be able to: Introduce methods of analyzing.
The Software Development Process
Chapter One An Introduction to Programming and Visual Basic.
Data Structures Using C++ 2E
Top-down approach / Stepwise Refinement & Procedures & Functions.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
The Hashemite University Computer Engineering Department
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Strategies & Knowledge for Independent Learning individual Work SKIL SKIL cards are sets of cards that explain how to use different learning strategies.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Thinking Mathematically Problem Solving. Polya’s Four Steps Understand the problem Devise a plan Carry out the plan and solve the problem Look back and.
Selection Using IF THEN ELSE CASE Introducing Loops.
Algorithms and Flowcharts
A451 Theory – 7 Programming 7A, B - Algorithms.
Learning to Program in Python
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter One: An Introduction to Programming and Visual Basic
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 15 Debugging.
Presentation transcript:

Foundations of Problem Solving chapter 2 Dr Lahen Ouarbya

Outcomes –This chapter is all about problems and how we solve them –Problem-solving is the heart of programming –What is a problem? –The problem with problem solving –A strategy for solving problems –Understanding the problem –Devising and carrying out the plan – Assessing the results –Describing what we have learned –Documenting the solution Applying the strategy 2

–When you get a new gadget do you: (a)Fully read the instructions before switching it on and using it? (b) Start playing with it learning how it works by trial and error and using the instructions only when you get stuck? –Too many beginning programmers get a programming assignment and immediately start writing code before they have thoroughly understood the problem –“Hours spent playing with a new software package can save minutes reading the manual” –This leads to frustration and confusion

What is a problem? –Before we write any code we must understand and solve the underlying problem –A problem exists when –We have an (as yet) unreached goal and –Several possible ways of attaining that goal –A programming problem might be something like: –“Calculate the cost (including tax and delivery) of a shopping basket of items at an online store and the customer a receipt” –“Whenever the main character in a game is in the castle grounds send the nearest zombie character to fight him” –“Rip a track from a CD and save it as an MP3 file” –The trick is to understand what is required

The problem with problems? –Problems can be difficult They may require intuitive leaps (e.g. cryptic crossword puzzles) Even the most systematic problem-solving technique –still requires you to think for yourself –In programming, the chosen programming language may introduce its own set of sub-problems to solve. Consider the following activity, a nice problem of arithmetic... 5

Example 1.A certain car has a fuel tank with a capacity of 60 litres and an average fuel consumption of 14 km/l. How far can the car travel on one tank of fuel, and how many litres are needed to travel 650 km? 2.How many times must you refuel to travel 2000 km? 6

Problem domain vs language domain –The first problem in the activity was straightforward. –The 2nd is a refinement of the first problem –We can we write an algorithm to solve all general problems of this type where the tank capacity and fuel consumption vary? –range = capacity × fuel_consumption –fuel_required = distance ÷ fuel_consumption –range = 60 × 14 = 840 km –fuel for 650 km = 650 ÷ 14 = –or 46? or 46.4 or 46.43? etc. –Sub-problem = how many digits to display? Should everything be displayed as a decimal fraction? Different programming languages handle display of numbers differently possibly introducing a tricky problem 7

Problem solving strategy 1.Understand the problem 2.Create a plan to solve the problem 3.Carry out the plan/attack 4.Assess the result, i.e. look back — check the result and reflect upon it 5.Describe what we have learnt from the process 6.Explain our results (and document our program) 8

1-Understand the problem –Read it through several times Identify the principal parts –Restate/rephrase the problem, use a different representation (e.g. draw a diagram) –What is the known? What is the unknown? Is finding the unknown part of the problem? –Does the problem have sub problems? –Is it similar to problems you have solved before? –How do the parts of the problem relate to each other?

2-Put together a plan ( create a plan) –Identify all sub-problems –Treat each sub-problem as a problem in its own right –What are some of the sub-problems of the larger problem “Describe how to get up and ready in the morning”? –Solve the easy sub-problems first –If too difficult, try simplifying the problem and solve the simpler version first –Make a drawing or sketch –Rewrite the problem in your own words to someone else

Example –Try partitioning (separating out) –the problem of getting up in the morning into a few simpler sub- problems (or tasks).

3-Carrying out the plan –If you are satisfied that you have a firm grasp on the solution, write down the sequence of actions necessary to solve the problem –Is the ordering of the actions correct? Does the order rely on certain conditions to be true? –Have these conditions come from the problem statement or are they assumptions you have made? –Is it possible to verify the assumptions? –If you are finding understanding a problem too complicated try removing some of the details to see if the simplification gives you a clearer understanding

Example –Write down the sequence in which the various actions associated with getting up in the morning should be carried out –Do all actions need to carried out in all circumstances? –Are some actions dependent on certain conditions being met? –Do some actions need to be repeated? (e.g. emptying the grass box on a lawnmower) –Are there any optional or conditional tasks involved in getting up in the morning?

4-Assessing the results –Run through your solution (sequence of actions) –Ideally, get someone else to work through them – they may just find instructions that mean something quite different from what you intended. –It is the differences between what we intend, and how we actually express our intentions that result in bugs (defects) in our programs –Did they manage to complete the task without asking for help or clarification?

Activity to assess the results –Get your friend to evaluate/criticize your steps for getting up in the morning that you wrote down earlier. –Did your solution give the right outcome or the correct results? –If you change some of the values and conditions do you still get the correct answers? If you did get the right answers, did any parts of the solution seem inefficient? is there a better way of doing things? –If you got the wrong answers, do you know why? Trace through your solution step by step to see if you can find where it is going wrong. –This step of assessing the result is very important as it will highlight errors in the solution and areas that could be improved. You should repeat steps 2, 3, and 4 until you are as confident as you can reasonably be that your solution is the best one you can achieve. Only then should you move on to...

5-Describing what we have learnt –Having gone through several cycles of devising a plan, carrying out the plan, and assessing the results you should have a list of things you have learnt –Write down these helps you to build a repertoire of good practice and mistakes –You will find this repertoire useful when you solve similar problems in the future

Documenting the solution –In addition to your solution write down –A general summary of the solution –Assumptions that have been made which affect the way the solution works. –Conditions that must be met before the solution can be applied (e.g. before you can apply the solution to getting up in the morning a supply of clothes must be available)

Reading –Read chapter on HTTLP book –Do exercise all exercises.