1 Chapter 2 Problem Solving Techniques. 2 2.1 INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Chapter 2: Problem Solving
Chapter 2: Problem Solving
ITEC113 Algorithms and Programming Techniques
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 3 Planning Your Solution
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
1 L07SoftwareDevelopmentMethod.pptCMSC 104, Version 8/06 Software Development Method Topics l Software Development Life Cycle Reading l Section 1.4 – 1.5.
The University of Texas – Pan American
Chapter 2: Problem Solving
CSEB114: PRINCIPLE OF PROGRAMMING Chapter 2: Problem Solving.
Chapter 2: Problem Solving
U NDERSTANDING P ROBLEMS AND HOW TO S OLVE THEM BY USING C OMPUTERS.
Simple Program Design Third Edition A Step-by-Step Approach
Programming Lifecycle
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Slide 1 Software Development 1. Requirement Specification 2. Analysis 3. Algorithm Design 4. Implementation 5. Testing 6. Documentation.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
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.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CMSC 1041 Algorithms II Software Development Life-Cycle.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
กระบวนการแก้ปัญหาด้วย คอมพิวเตอร์ 3 พฤษภาคม :00-17:00.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
PROGRAMMING PAPER 2 AS Algorithms.
ITEC113 Algorithms and Programming Techniques
Chapter 2: General Problem Solving Concepts
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
Principles of Programming - NI July Chapter 2: Problem Solving In this chapter you will learn about: Introduction to Problem Solving Software development.
1 Program Planning and Design Important stages before actual program is written.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Structured Programming (4 Credits)
 In this chapter you will learn about:  Introduction to Problem Solving  Software development method (SDM)  Specification of needs  Problem analysis.
CSEB114: Principle of programming
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Programming Fundamentals Introduction to Problem Solving  Programming is a problem solving activity. When you write a program, you are actually writing.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Algorithms IV Top-Down Design.
Algorithms II Software Development Life-Cycle.
Unit 3: ALGORITHMS AND FLOWCHARTS
SOFTWARE DEVELOPMENT METHOD
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
Algorithm & Programming
Algorithms and Flowcharts
Programming Fundamentals
ALGORITHMS AND FLOWCHARTS
Problem Solving Techniques
Structured Program
Programming Fundamentals (750113) Ch1. Problem Solving
ALGORITHMS AND FLOWCHARTS
Chapter 1 Introduction(1.1)
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Understanding Problems and how to Solve them by using Computers
Programming Fundamentals (750113) Ch1. Problem Solving
ICT Gaming Lesson 2.
Introduction to Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Basic Concepts of Algorithm
Structural Program Development: If, If-Else
Presentation transcript:

1 Chapter 2 Problem Solving Techniques

2 2.1 INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD

3 consists of the following steps : 1. Requirements specification 2. Analysis 3. Design 4. Implementation 5. Testing and verification 6. Documentation divide and conquer split the problem into several simpler subproblems, solve each individually, and then combine these solutions.

4 2.4 REQUIREMENTS SPECIFICATION understanding exactly what the problem is, what is needed to solve it, what the solution should provide. 2.5 ANALYSIS identify the following : 1. Inputs to the problem 2. Outputs expected from the solution 3. Any special constraints or conditions 4. Formulas or equations to be used

5 2.6 DESIGN AND REPRESENTATION OF ALGORITHMS An algorithm is a sequence of a finite number of steps arranged in a specific logical order, which, when executed, produce the solution for a problem. An algorithm is a procedure that takes a set of values as input and transforms them into a set of values as output In practice we expect algorithms to be efficient.

6 Pseudocoding The main purpose of a pseudocode language is to define the procedural logic of an algorithm requirements: 1. Have a limited vocabulary 2. Be easy to learn 3. Produce simple, English-link narrative notation 4. Be capable of describing all algorithms

7 The Sequence Control Structure is a series of steps or statements that are executed in the order in which they are written in an algorithm read taxable income read filing status compute income tax print income tax Figure 2.1 A sequence control structure

8 The Selection Control Structure define two courses of action, depending on the outcome of a condition. if condition then-part else else-part end_if the else-part may be missing.

9 A nested selection structure contains other if/else structures in its then-part or else-part. if status is equal to 1 print “single” else if status is equal to 2 print “Married filing jointly” end_if

10 if status is equal to 1 print “Single” end_if if status is equal to 2 print “Married filing jointly” end_if

11 The Repetition Control Structure specifies a block of one of one or more statements that are repeatedly executed until a condition is satisfied. while condition loop-body end_while loop-body is a single statement or a block of statements

12 Print “Enter taxable income; should be greater than or equal to $50,000.00” read income while income is less than begin print “Enter taxable income; should be greater than or equal to $50,000.00” read income end end_while

13 Conventions for Pseudocoding 1.Each pseudocode statement includes keywords 2.Each pseudocode statement should be written on a separate line. 3.Statements in a sequence structure can be grouped into a block 4.For the selection control structure, use an if/else statement. 5.For the repetition control structure, use the while statement 6.All words in a pseudocode statement must be unambiguous and as easy as possible for nonprogrammers to understand.

14 Structure chart, as in figure 2.6. This chart indicates that the original problem is solved if the four subproblems at the lover level of hierarchy are solved from left to right.

15 set correctStatusInput to “no” print “FILING STATUS MENU:” print “Single----1” print “Married filing jointly----2” print “Married filing separately ----3” print “Head of household----4” while correctStatusInput is equal to “no” begin print “Enter filing status; should be between 1 and 4:” read filingStatus if filingStatus is greater than 0 if filingStatus is less than 5 set correctstatusInput to “yes” end_if end end_while Figure 2.7 Final refinement of read and verify filing status

16 if filingStatus is 1 compute tam = * (income – ) else if filingStatus is 2 if income is less than or equal to 82,150 compute tax = * (income – ) else compute tax = * (income – ) end_if else if filingStatus is 3 compute tax = * (income – ) else if status is 4 if income is less than or equal to compute tax = * (income – ) else compute tax = * (income – ) end_if Figure 2.8 Final refinement of compute tax (continued)

17 print income if filingStatus is equal to 1 print “Single” else if filingStatus is equal to 2 print “Married filing jointly” else if filingStatus is equal to 3 print “ married filing separately” else if filingStatus is equal to 4 print “Head of household” end_if print tax Figure 2.9 Final refinement of print income, filing status, and tax

18 Algorithm design technique 1.Use the divide-and-conquer strategy to split the original problem into a series of subproblems. 2.Consider each subproblem separately and further split them into subproblems, until no further refinement is possible. Stop the process when you have a pseudocode that can be directly translated into a C program. 3.Combine all final refinements

19 Flowcharting alternative to pseudocoding; flowchart is a graph consisting of geometrical shapes the geometrical shapes in a flowchart represent the types of statements in an algorithm. The details of statements are written inside the shapes. The flow lines show the order in which the statements of an algorithm are executed. Two geometrical shapes used in flowcharting are the rectangle, which represents processes such as computations, assignments, and initializations, and the diamond-shaped box, which stands for the keyword if in pseudocode, with the if condition written inside the box.

20

21

22

23

24

IMPLEMENTATION translate each step of the algorithm into a statement in that particular language Programming Errors debugging three types of programming errors : 1. design errors : occur during the analysis,design, and implementation phases. 2. Syntax error : detected by the compiler during the compilation process. 3. Run-time errors : detected by the computer while your program is being executed. Divide a number by zero.

TESTING AND VERIFICATION A program must be tested using a sufficiently large sample of care fully designed test data sets such that every logical path in the program is traversed at least once.

PROGRAM DOCUMENTATION 1. A concise requirements specification 2. Descriptions of problem inputs, expected outputs, constraints, and applicable formula. 3. A pseudocode or flowchart for its algorithm 4. A source program listing 5. A hard copy of a sample test run of the program 6. A user’s guide explaining to nonprogrammer users how the program should be used (optional)