Problem Solving and Program Planning

Slides:



Advertisements
Similar presentations
PSEUDOCODE & FLOW CHART
Advertisements

Selection (decision) control structure Learning objective
Chapter 1 - An Introduction to Computers and Problem Solving
Subject: Information Technology Grade: 10
Faculty of Sciences and Social Sciences HOPE Structured Problem Solving Week 5: Steps in Problem Solving Stewart Blakeway FML 213
Defining Control Structures
Chapter 2: Design of Algorithms
ACSE th Conference The Iconic Programmer Stephen Chen.
Developing logic (Examples on algorithm and flowchart)
Chapter 3 Planning Your Solution
Algorithm & Flowchart.
Imagine a program that starts ALL OVER AGAIN if they get even one answer wrong! THIS ONE DOES! Imagine a program that is SELF-CORRECTING! THIS ONE IS!
Exponents Powerpoint Fun Quiz! Your students will LOVE this! A great power point program to test and reinforce their knowledge of exponents. This is just.
ALGORITHMS AND FLOWCHARTS
Computer Programming 12 Lesson 2 - Organizing the Problem By Dan Lunney.
THE PROBLEM SOLVING PROCESS BDP301. Stages and Skills in the Problem Solving Process  The problem solving process has 3 stages: Problem finding, idea.
Algorithms In general algorithms is a name given to a defined set of steps used to complete a task. For example to make a cup of tea you would fill the.
C++ If….Else Statements and Flowcharts October 10, 2007.
Problem Solving and Decision Making Techniques Leadership Certification Level 1 Linda Koh.
Flowcharts! January 13, 2005 These are today’s notes! Do you think we will get more snow?
End Show Writing a computer program involves performing the following tasks. 1. Understanding the problem 2. Developing an Algorithm for the problem 3.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
30/10/ Iteration Loops Do While (condition is true) … Loop.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Procedural Programming. Programming Process 1.Understand the problem 2.Outline a general solution 3.Decompose the general solution into manageable component.
Halting Problem Introduction to Computing Science and Programming I.
Agenda Basic Logic Purpose if statement if / else statement
`. Lecture Overview Structure Programming Basic Control of Structure Programming Selection Logical Operations Iteration Flowchart.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Chapter 7 Problem Solving with Loops
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
GCSE Computing: Programming GCSE Programming Remembering Python.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
Lecture 5: Layers of Control. Nested while Loops Problem Multiplying two numbers and outputting the result only if they are both less than 5. (i.e. Start.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Conditionals.
An Introduction to Programming with C++1 Beginning the Problem- Solving Process Tutorial 2.
Flow Charts And Pseudo Codes Grade 12. An algorithm is a complete step-by- step procedure for solving a problem or accomplishing a task.
 Problem Analysis  Coding  Debugging  Testing.
Algorithms and Flowcharts
BIT116: Scripting Lecture 05
CS1010 Programming Methodology
Introduction to Computing Science and Programming I
Algorithms and Flowcharts
Chapter 4: Control Structures
Numbering System TODAY AND TOMORROW 11th Edition
ALGORITHMS AND FLOWCHARTS
Print slides for students reference
Conditions and Ifs BIS1523 – Lecture 8.
SCIENTIFIC METHOD VOCABULARY.
MSIS 655 Advanced Business Applications Programming
1) C program development 2) Selection structure
ALGORITHMS AND FLOWCHARTS
flow charts and system diagrams
Do While (condition is true) … Loop
Introduction to Algorithms and Programming
Flowcharts and Pseudo Code
Basic Concepts of Algorithm
Program Correctness an introduction.
Presentation transcript:

Problem Solving and Program Planning ICS4U – Computer Science

Overview Problem Solving Planning Samples Practice Assignment Problem Solving Model Planning Problem-Definition Table Input-Processing-Output Chart Pseudocode Flowcharting Samples Practice Assignment

Problem Solving

Solve the following problem: A flower has been placed in a coloured box. Each box carries a statement. Of the three statements, at most, only one is true. Which box contains the flower? If you solve it, think about how you got to your solution. Will visit the solution at the end. RED The flower is in this box. YELLOW The flower is not in this box. GREEN The flower is not in the red box.

Problem Solving Model

Identify the problem What is the current situation/problem? What is the problem to be solved?

Analyze the problem What do we know already about the situation/problem? What are our assumptions? What is the knowledge base of the person for whom we're trying to problem-solve? What can or do they understand? What don't we know yet about the whole situation/problem?

Brainstorm ideas List all possible ideas to solve the problem. No value judgment is to be passed on any suggestions. The more ideas, the better.

Prioritize ideas Establish pros and cons of each suggestion in step 3. Rank the suggested ideas from step 3 according to a set criteria.

List the steps to be taken following the chosen solution What are the steps/instructions we should take according to the top solution ranked in step 4? Will these steps/instructions be understood according to the knowledge base established in step 2?

Evaluate/Test the Solution Do we have the desired results after following the steps in 5? Does the solution satisfy the needs of the person with the problem? What are some of the areas that are not correct/satisfactory? (back to step1)

Planning

Problem-Definition Table Known Facts User Requirements Necessary Processing What are some of the given facts? Do we need to gather more facts first? What does the user want done and what is the user required to do? What are the steps we have to take to produce user requirements?

Input-Processing-Output Chart Input Data Processing Steps Output Data Fill this FIRST Fill this SECOND Fill this THIRD

Pseudocode Step-by-step English explanation of how to solve the problem.

Pseudocode for a Grading Program If student's grade is greater than or equal to 50 Print "passed" else Print "failed"

Flowchart A diagram of the solution to the problem, using specific flowchart symbols.

Samples

Sample #1 Let’s look at the original problem A flower has been placed in a coloured box. Each box carries a statement. Of the three statements, at most, only one is true. Which box contains the flower? If you solve it, think about how you got to your solution. RED The flower is in this box. YELLOW The flower is not in this box. GREEN The flower is not in the red box.

Known Facts User Requirements Necessary Processing Problem-Definition Table Known Facts User Requirements Necessary Processing One box contains the flower Only 0 or 1 true statement exists Find the box that contains the flower Start from box 1 assuming it is true, and go through the statements in each box. Follow the true or false consequences of each statement to arrive at the solution

Input-Processing-Output Chart (next slide)

Input Data Processing Steps Output Data Each statement inscribed on each box If red box is true, then yellow must also be true. However this is not possible because we would have two true statements and we are given that only one statement at most can be true. If red is false, i.e., the flower is not in the red box, then the statement on the green box is true If the green box’s statement is true, then the yellow box’s statement must be false because there can be at most only 1 true statement. Therefore, the flower is in the yellow box The Yellow Box contains the flower

Pseudocode 1. Read in the three boxes’ statements 2. Assume the red box statement is true 3. If (red box’s statement is true) then The yellow box’s statement is also true, and we have a contradiction with what we are given, i.e. only 1 statement at maximum is true, but now we would have two true statements if red box’s statement is true, so 4. If (red box’s statement is false) then The flower is not in the red box, i.e., green box’s statement is true And the yellow must be false because we are given that only 1 statement at maximum is true, so 5. If (yellow box’s statement is false) then the flower is in the yellow box.

Sample #2 Amy has a favourite colour in mind. Try guessing this colour. If you guess correctly, Amy lets you know that you are right and the program stops. Otherwise, the program keeps on asking you for a guess. However, if you give up, just type in ZZZ to stop.

Known Facts User Requirements Necessary Processing Problem-Definition Table Known Facts User Requirements Necessary Processing There is one and only predetermined colour to guess The guess is typed in from the user If the guess is correct, a correct message is given and the program stops If the guess is wrong, the program keeps on asking for a guess until the guess is correct or the user types ZZZ Keep on guessing Amy’s favourite colour until the guess is correct or give up by typing ZZZ Assign a colour as Amy’s favourite colour Ask user to type in a guess While the guess is not equal to Amy’s colour and not equal to ZZZ, ask user to type in another guess If the guess is right, display a congratulations message End of program

Input Data Processing Steps Output Data Input-Processing-Output Chart Input Data Processing Steps Output Data A guess typed in by the user Assign a colour as Amy’s favourite colour Ask user to type in a guess While the guess is not equal to Amy’s colour and not equal to ZZZ, ask user to type in another guess If the guess is right, display a congratulations message End of program A congratulations message if the guess is correct.