Problem Decomposition and Abstraction. Problem Solving Which one is easier:  Solving one big problem, or  Solving a number of small problems?

Slides:



Advertisements
Similar presentations
Guide to Programming with Python
Advertisements

TIC-TAC-TOE FELIX CHEN CLUSTER 5: Computers in Biophysics and Robotics.
PLANNING THE TIC TAC TOE GAME BY NEEL DAVE. TIC TAC TOE INSTRUCTIONS Tic Tac Toe Instructions The basic concept of Tic Tac Toe 1.This is a game for two.
J AVA A SSIGNMENT 1. O VERVIEW Tic Tac Toe How it should work Using the supplied methods What you need to do How we will test your code.
Operations Research Assignment Problem.
1 CSE1301 Computer Programming: Lecture 23 Algorithm Design (Part 1)
Methods and Parameters in Java. Methods in Java Also known as  functions, procedures, subroutines For example  System.out.println()  Math.sqrt() Provide.
X Australian Curriculum Year 5 Solve problems involving multiplication of large numbers by one or two digit numbers using efficient mental, written strategies.
12 Pontoon1May Pontoon program CE : Fundamental Programming Techniques.
Prime Geometry Primes are a topic of enduring interest. “God gave us primes.” “Describe pictures to alien civilizations using N bits where N is the cube.
Chapter 2: Algorithm Discovery and Design
CSE1301 Computer Programming: Lecture 27 Game Programming: Bingo.
School of Computing Science CMT1000 © Ed Currie Middlesex University 1 CMT1000: Introduction to Programming Ed Currie Lecture 1B: Problem Solving.
Thomas algorithm to solve tridiagonal matrices
Program Design Divide and Conquer –Divide the program into separate tasks Functional Decomposition Top-Down Design –Divide an overall problem into discrete.
1 CSE1301 Computer Programming: Lecture 25 Software Engineering 2.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
New Mexico Computer Science For All Introduction to Algorithms Maureen Psaila-Dombrowski.
1 ENG236: Introduction (1) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Game Design For Development Brent M. Dingle 2014 Game Design and Development Program Mathematics, Statistics and Computer Science University of Wisconsin.
Building a Math Community
C OMPUTER S CIENCE G EMS 5 Challenging Projects. P ROJECT 1: M ASTERMIND Summary: A code breaking game 12 guesses Feedback is # correct and # correct.
X = 11 X 2 = 9 X = 3 Check: X = 3 x 3 +2 = 11 We can solve this equation by:
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science, Java Version, Second Edition.
Guide to Programming with Python Chapter Six Functions: The Tic-Tac-Toe Game.
CSE 219 Computer Science III Program Design Principles.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
Making Decisions uCode: October Review What are the differences between: o BlueJ o Java Computer objects represent some thing or idea in the real.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Lecture 4 Looping. Building on the foundation Now that we know a little about  cout  cin  math operators  boolean operators  making decisions using.
L061 Algorithms, Part 3 of 3 Topics Top down-design Structure charts Reading Sections , 3.3.
Applying the Distributive Property Lesson Application Problem O A parking structure has 10 levels. There are 3 cards parked on each level. How many.
Introduction to State Space Search
Program Development by Stepwise Refinement
Thinking is at the heart of Mathematics and therefore should be at the heart of mathematical teaching and learning.
THINKING PROCEDURALLY OR CONCURRENT (SIMULTANEOUSLY OR SIDE BY SIDE OR IN LOGICAL ORDER A- IDENTIFY THE COMPONENTS OF A PROBLEM B-IDENTIFY THE COMPONENTS.
Guide to Programming with Python Chapter Six Functions: The Tic-Tac-Toe Game.
6.2 Classes “ A class is basically a structure with member functions as well as member data. Classes are central to the programming methodology known as.
2-dimensional Arrays A 2-dimensional array has rows and columns It is actually an “array of arrays” A Tic-Tac-Toe board is an example of a 3 by 3 2-d array.
COMP 110: Spring Announcements Lab 7 was due today Binary Expression Assignment due Friday.
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
Today… Functions, Cont.: –Designing functions. –Functional Decomposition –Importing our own module –A demo: Functional solution to assignment 2. Winter.
Simplifying Radicals. You’ve already done some work with radicals and square roots such as: Finding the square root of perfect squares Estimate the square.
CST 1101 Problem Solving Using Computers
Applying the Distributive Property
Thinking is at the heart of Mathematics and therefore should be at the heart of mathematical teaching and learning.
Computational Thinking
Objective: Today we will investigate the ‘magic’ in magic squares.
Align The Stars Continue.
GET READY SETTLER ACTIVITY
The Friendship Algorithm
Topic 1: Problem Solving
Global Challenge Walking for Water Lesson 2.
Algorithms.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Align The Stars Continue.
Global Challenge Walking for Water Lesson 2.
Computational Thinking
Global Challenge Walking for Water Lesson 2.
Quiz: Computational Thinking
Computational Thinking
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Presentation transcript:

Problem Decomposition and Abstraction

Problem Solving Which one is easier:  Solving one big problem, or  Solving a number of small problems?

Problem Solving Which one is easier:  Solving one big problem, or  Solving a number of small problems? What are the advantages of small problems?

Problem Solving Which one is easier:  Solving one big problem, or  Solving a number of small problems? What are the advantages of small problems?  Easier to solve  Easier to ensure the solution is correct In order to have a number of small problems  What do we need to do first?

Common Mistake Dive into the details  (e.g. at the level of Java instructions) Do not consider decomposing the problem first  “in English”

Tic-tac-toe We would like to build a tic-tac-toe game that a human can play against another How would you decompose the problem?

Problem Decomposition 1. Display the board 2. Make a move 3. Decide winner Can these smaller problems be independently  solved?  tested?

Decide Winner Seems to be complicated, what can we do?

Decide Winner Seems to be complicated, what can we do?  Decompose!

Decide Winner Seems to be complicated, what can we do?  Decompose! a. Check 3 rows b. Check 3 columns c. Check 2 diagonals  Can they be independently  Solved?  Tested?

Top-down Decomposition 1. Display the board 2. Make a move 3. Decide winner a. Check 3 rows b. Check 3 columns c. Check 2 diagonals

Make a Move Decompose:

Make a Move Decompose:  Ask for a move  Update the board

Top-down Decomposition 1. Display the board 2. Make a move a. Ask for a move b. Update the board 3. Decide winner a. Check 3 rows b. Check 3 columns c. Check 2 diagonals Two levels of abstraction

When to stop decomposing a problem?

Until you’re confident you can solve the smaller problems correctly  Different for different people

Make a Move Recall there are two human players Who makes a move?

Make a Move Do we want  To break it down to  2 smaller problems, each for a player  One problem that is  flexible for the 2 players ?

Make a Move Do we want  To break it down to  2 smaller problems, each for a player  One problem that is  flexible for the 2 players Prefer one problem that is flexible for 2 situations  The 2 smaller problems are very similar  Solving 2 similar problems is tedious  Rewriting almost the same instructions

Make a Move makeAMove(player)  Similar to sqrt(x)  makeAMove can be used with different players Problem abstraction  via parameters

Summary Problem decomposition  Top-down  Decompose until you’re confident you can solve the small problems correctly.

Summary Problem decomposition  Top-down  Decompose until you’re confident you can solve the small problems correctly. Problem abstraction  Different levels of abstraction in top-down decomposition  More general to more specific  Increase abstraction via parameters  Allow the solution to be reused in different situations  Avoid repeatedly writing almost the same instructions