This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ProblemSolving Process
1. 2. 3. 4. 5. State the Problem (Problem Specification) Analyze the problem: outline solution requirements and design an initial algorithm and Design and refine the algorithm to solve the problem, verify the algorithm, come up with a test plan plan Implement the algorithm in a programming language (Java) and verify that the algorithm works language Maintain the program: use and modify if the problem domain changes problem 1 © Janice Regan 2004 Problem Specification Any problem solving process consists Any of Input Algorithm Output Determine what information is Determine available as input to your algorithm available Determine what information is desired Determine as output from your algorithm as © Janice Regan 2004 2 Design a basic algorithm Design An algorithm is Any Any set of instructions that specifies a series of steps to correctly solve the problem of There may be many different algorithms There to solve a given problem to Some algorithms may be more efficient Some than others than © Janice Regan 2004 3 Properties of Good Algorithms Efficiency Simplicity Precision Effectiveness Generality Levels of Abstraction Correctness Finiteness Maintainability © Janice Regan 2004 4 Algorithms and Programs An algorithm is a finite set of instructions that An explains the required solution stepbystep explains A computer can be instructed to implement many computer algorithms with a finite number of steps or instructions instructions A program is a set of computer instructions that program implements an algorithm implements © Janice Regan 2004 5 Refine the algorithm Identify special cases Determine how to test to demonstrate that the Determine algorithm works for all cases (including special cases) special Verify that the algorithm is logically valid The algorithm must give the correct answer, in a The finite number of reproducible steps finite The algorithm must terminate when the answer is The determined determined © Janice Regan 2004 6 Implement the algorithm Translate the algorithm into a programming Translate language. language. Make sure the implementation has correct Make syntax and semantics (it compiles) syntax Make sure the implementation is logically Make correct correct Test and make sure the implementation works Test for all normal and special cases for © Janice Regan 2004 7 ProblemAnalysisCodingExecution Cycle © Janice Regan 2004 8 Class discussion Algorithm for solving a quadratic equation © Janice Regan 2004 9 Programming Methodologies Two basic approaches to programming design: Structured design (process oriented)
Centered on ‘What is happening’ Code (procedures) acting on data Think in terms of breaking into tasks to be completed Think Objectoriented design
Centered on ‘Who or what data is being affected’ Data controlling access to code Think in terms of data entities, interfaces to that data, Think and processes or methods applied to that data and © Janice Regan 2004 10 Structured Design
1. A problem is divided into smaller problem subproblems subproblems 2. Each subproblem is solved 3. The solutions of all subproblems are then The combined to solve the problem combined © Janice Regan 2004 11 ObjectOriented Design (OOD) In OOD, a program is a collection of In interacting objects interacting An object consists of data and operations Steps in OOD:
1. 2. 3. Identify objects Form the basis of the solution Determine how these objects interact © Janice Regan 2004 12 ...
View
Full
Document
This note was uploaded on 01/16/2010 for the course CMPT 101 taught by Professor Various during the Spring '03 term at Simon Fraser.
 Spring '03
 various

Click to edit the document details