Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Module 3: Classifying Problems One of the main themes of this course will be to classify problems in various ways –By solvability Solvable, “half-solvable”,

Similar presentations


Presentation on theme: "1 Module 3: Classifying Problems One of the main themes of this course will be to classify problems in various ways –By solvability Solvable, “half-solvable”,"— Presentation transcript:

1 1 Module 3: Classifying Problems One of the main themes of this course will be to classify problems in various ways –By solvability Solvable, “half-solvable”, unsolvable We will focus our study on decision problems –function (one correct answer for every input) –finite range (yes or no is the correct output)

2 2 Classification Process Take some set of problems and partition it into two or more subsets of problems where membership in a subset is based on some shared problem characteristic Set of Problems Subset 1Subset 2Subset 3

3 3 Classify by Solvability Criteria used is whether or not the problem is solvable –that is, does there exist a C++ program which solves the problem? Set of All Problems Solvable ProblemsUnsolvable Problems

4 4 Function Problems We will focus on problems where the mapping from input to output is a function Set of All Problems Non-Function ProblemsFunction Problems

5 5 General (Relation) Problem the mapping is a relation –that is, more than one output is possible for a given input Inputs Outputs

6 6 Criteria for Function Problems mapping is a function –unique output for each input Inputs Outputs

7 7 Example Non-Function Problem Divisor Problem –Input: Positive integer n –Output: A positive integral divisor of n Inputs Outputs 9 1 3 9

8 8 Example Function Problems Sorting Multiplication Problem –Input: 2 integers x and y –Output: xy Inputs Outputs 2,5 10

9 9 Another Example * Maximum divisor problem –Input: Positive integer n –Output: size of maximum divisor of n smaller than n Inputs Outputs 9 1 3 9

10 10 Decision Problems We will focus on function problems where the correct answer is always yes or no Set of Function Problems Non-Decision ProblemsDecision Problems

11 11 Criteria for Decision Problems Output is yes or no –range = {Yes, No} Note, problem must be a function problem –only one of Yes/No is correct Inputs Outputs Yes No

12 12 Example Decision sorting –Input: list of integers –Yes/No question: Is the list in nondecreasing order? Inputs Outputs Yes No (1,3,2,4) (1,2,3,4)

13 13 Another Example Decision multiplication –Input: Three integers x, y, z –Yes/No question: Is xy = z? Inputs Outputs Yes No (3,5,14) (3,5,15)

14 14 A Third Example * Decision Divisor Problem –Input: Two integers x and y –Yes/No question: Is y a divisor of x? Inputs Outputs Yes No (14,5) (14,7)

15 15 Focus on Decision Problems Set of All Problems Solvable ProblemsUnsolvable Problems Decision Problems Other Probs When studying solvability, we are going to focus specifically on decision problems –There is no loss of generality, but we will not explore that here

16 16 Finite Domain Problems These problems have only a finite number of inputs Set of All Problems Finite Domain ProblemsInfinite Domain Problems

17 17 Lack of Generality Set of All Problems Solvable ProblemsUnsolvable Problems All finite domain problems can be solved using “table lookup” idea Finite Domain Infinite Domain Empty

18 18 Table Lookup Program int main(string x) { switch x { case “Bill”: return(3); case “Judy”: return(25); case “Tom”: return(30); default: cerr << “Illegal input\n”; }

19 19 Key Concepts Classification Theme Decision Problems –Important subset of problems –We can focus our attention on decision problems without loss of generality –Same is not true for finite domain problems Table lookup


Download ppt "1 Module 3: Classifying Problems One of the main themes of this course will be to classify problems in various ways –By solvability Solvable, “half-solvable”,"

Similar presentations


Ads by Google