problem solving algorithm design - york university · problem solving & algorithm design. 01-2...

31
01-1 Problem Solving & Algorithm Design

Upload: others

Post on 22-Jun-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-1

Problem Solving&

Algorithm Design

Page 2: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-2

Problem solving

•  The act of finding a solution to a perplexing, distressing, vexing, or unsettled question

Page 3: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-3

How to Solve it• Written by George Polya in 1945

Page 4: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-4

How to Solve it• Written by George Polya in 1945

» It is written in a mathematical context for mathematical problems

Page 5: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-5

How to Solve it• Written by George Polya in 1945

» It is written in a mathematical context for mathematical problems

> With simple wording changes his list of suggestions are applicable to all types of problems

Page 6: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-6

Ask Questions•  To understand a problem

Page 7: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-7

Ask Questions•  To understand a problem

» What do I know about the problem?

Page 8: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-8

Ask Questions•  To understand a problem

» What do I know about the problem?

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

Page 9: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-9

Ask Questions•  To understand a problem

» What do I know about the problem?

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

» What does the solution look like?

Page 10: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-10

Ask Questions•  To understand a problem

» What do I know about the problem?

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

» What does the solution look like?

» What sort of special cases exist?

Page 11: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-11

Ask Questions•  To understand a problem

» What do I know about the problem?

» What is the information that I have to process in order to 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 12: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-12

Look for Familiar Things» You should never “reinvent the wheel”

Page 13: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-13

Look for Familiar Things» You should never “reinvent the wheel”

» In computing, you see certain problems again in different guises

Page 14: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-14

Look for Familiar Things» You should never “reinvent the wheel”

»  In computing, you see certain problems again in different guises

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

Page 15: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-15

Divide and conquer» Break up a large problem into smaller units

that can be handled more easily

Page 16: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-16

Divide and conquer» Break up a large problem into smaller units that

can be handled more easily

» Abstraction plays an important role

Page 17: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-17

Divide and conquer» Break up a large problem into smaller units that

can be handled more easily

» Abstraction plays an important role

» The divide-and-conquer approach can be applied over and over

Page 18: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-18

AbstractionAn explanation, idea or model that

removes complex details

This is a key conceptAbstraction will reappear throughout the course

Page 19: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-19

Algorithm

A technical term for a set of instructions for solving a problem or sub-problem

Page 20: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-20

Algorithm

A technical term for a set of instructions for solving a problem or sub-problem

Desirable PropertiesUse a finite amount of time

Page 21: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-21

Algorithm

A technical term for a set of instructions for solving a problem or sub-problem

Desirable PropertiesUse a finite amount of time

Use a finite amount of data, material

Page 22: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-22

Algorithm

A technical term for a set of instructions for solving a problem or sub-problem

Desirable PropertiesUse a finite amount of time

Use a finite amount of data, materialInstructions are unambiguous

Page 23: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-23

Who writes algorithms?

Page 24: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-24

Who writes algorithms?

Anyone who wants to write a set of instructions for solving a problem

Page 25: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-25

An Example AlgorithmHow to prepare Hollandaise sauce

Page 26: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-26

Algorithm Written in PseudocodeA mixture of English and formatting to make the steps in the algorithm explicit

Put butter in a potTurn on burner (low heat)Put pot on the burner While (not bubbling) Leave pot on the burner Turn off burner Put other ingredients in the blender Turn on blender While (more butter needed) Pour butter into blender in a slow stream Turn off blender

Page 27: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-27

Developing an Algorithm•  Implementing an algorithm involves making

it computer-readable

Page 28: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-28

Developing an Algorithm•  Implementing an algorithm involves making

it computer-readable» Must be in a suitable form for a computer

Page 29: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-29

Developing an Algorithm•  Implementing an algorithm involves making

it computer-readable» Must be in a suitable form for a computer

•  The methodology (set of working methods) used to make the plan must

Page 30: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-30

Developing an Algorithm•  Implementing an algorithm involves making

it computer-readable» Must be in a suitable form for a computer

•  The methodology (set of working methods) used to make the plan must» Begin with a problem statement

Page 31: Problem Solving Algorithm Design - York University · Problem Solving & Algorithm Design. 01-2 Problem solving • The act of finding a solution to a perplexing, distressing, vexing,

01-31

Developing an Algorithm•  Implementing an algorithm involves making

it computer-readable» Must be in a suitable form for a computer

•  The methodology (set of working methods) used to make the plan must» Begin with a problem statement

» Conclude with a plan that can be easily coded