21
6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

  • View
    222

  • Download
    1

Embed Size (px)

Citation preview

Page 1: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-1

Problem Solving

• Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

Page 2: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-2

Problem Solving

• G. Polya wrote How to Solve It: A New Aspect of Mathematical Method

• His How to Solve It list is quite general – Written in the context of solving

mathematical problems– The list becomes applicable to all

types of problems

Page 3: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-3

Ask Questions...

• …to understand the problem

– What do I know about the problem?

– What is the information that I have to process in order the find the solution?

– What does the solution look like?

– What sort of special cases exist?

– How will I recognize that I have found the solution?

Page 4: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-4

Look for Familiar Things

• You should never reinvent the wheel

• In computing, you see certain problems again and again in different guises

• A good programmer sees a task, or perhaps part of a task (a subtask), that has been solved before and plugs in the solution

Page 5: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-5

Divide and Conquer

• Break up a large problem into smaller units that we can handle

– Applies the concept of abstraction

– The divide-and-conquer approach can be applied over and over again until each subtask is manageable

Page 6: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-6

Algorithms

• An algorithm is set of instructions for solving a problem or subproblem in a finite amount of time using a finite amount of data

• The instructions are unambiguous

Page 7: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-7

Pseudocode

• Uses a mixture of English and formatting to make the steps in the solution explicit

Page 149

Page 8: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-8

Following an Algorithm

• Preparing a Hollandaise sauce

Figure 6.4

Page 9: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-9

Following an Algorithm (cont.)

• Preparing a Hollandaise sauce

Page 150

Page 10: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-10

Developing an Algorithm

• The plan must be suitable in a suitable form

• Two methodologies that currently used– Top-down design – Object-oriented design

Page 11: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-11

Top-Down Design

• Breaking the problem into a set of subproblems called modules

• Creating a hierarchical structure of problems and subproblems

Page 12: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-12

Top-Down Design

• This process continues for as many levels as it takes to expand every task to the smallest details

• A step that needs to be expanded is an abstract step

Figure 6.5 An example of top-down design

Page 13: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-13

A General Example

• Planning a large party

Figure 6.6 Subdividing the party planning

Page 14: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-14

A Computer Example

• Problem

– Create an address list that includes each person’s name, address, telephone number, and e-mail address

– This list should then be printed in alphabetical order

– The names to be included in the list are on scraps of paper and business cards

Page 15: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-15

A Computer Example

Page 156

Page 16: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-16

A Computer Example

Page 157

Page 17: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-17

A Computer Example

Page 158

Page 18: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-18

A Computer Example

Page 159

Page 19: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-19

Top-Down Methodology

• Analyze the Problem

• Write the Main Module

• Write the Remaining Modules

• Re-Sequence and Revise as Necessary

Page 20: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-20

Testing the Algorithm

• The process itself must be tested

• Testing at the algorithm development phase involves looking at each level of the top-down design

Page 21: 6-1 Problem Solving Problem solving is the act of finding a solution to a perplexing, distressing, vexing, or unsettled question

6-21

Testing the Algorithm

• Desk checking: sit at a desk with a pencil and paper and work through the design

• Walk-through: Manual simulation of the design by the team members– Take sample data values and simulate the design

using the sample data

• Inspection: The design is handed out in advance, and one person (not the designer) reads the design line by line while the others point out errors