Download presentation

Presentation is loading. Please wait.

1
1 Lecture 4 Topics –Problem solving Subroutine Theme –REC language class The class of solvable problems Closure properties

2
2 Problem Solving Solving problems –In this course, we spend a lot of time proving there are unsolvable problems –In today’s class, we will spend time doing the opposite: solving problems Subroutines –Using an algorithm for one problem to help build an algorithm to solve a second problem

3
3 Problem 1 Prime Number Problem –Input: Positive integer n –Yes/No Question: Is n a prime number? Questions –What kind of problem is this? –Construct a solution to this problem

4
4 Problem 2 Maximum clique problem –Input: Graph G = (V,E) list of nodes and edges –Output: Size of maximum clique in G Definitions –V: Set of n nodes {v i | 1 <= i <= n} –E: Set of edges {(v i, v j )} –Clique: subset C of V such that there is an edge between all nodes in C

5
5 Example v1v1 v2v2 v3v3 v4v4 v5v5 v6v6 V = {v 1, v 2, v 3, v 4, v 5, v 6 } E = {(v 1, v 2 ), (v 1, v 5 ), (v 1, v 6 ), (v 2, v 3 ), (v 2, v 4 ), (v 3, v 4 ), (v 4, v 5 ), (v 5, v 6 )} Question: How could we encode a graph as a string?

6
6 Example 2 v1v1 v2v2 v3v3 v5v5 v6v6 V = {v 1, v 2, v 3, v 4, v 5, v 6 } E = { Max clique size? Smallest number of edges needed to increase m. c. size? v4v4

7
7 Algorithm 1 Construct an algorithm for solving the max clique problem

8
8 Problem 2’ Decision clique problem –Input: Graph G = (V,E), integer k Note the extra input object k –Yes/No question: Does the maximum clique in G have size at least k?

9
9 Subroutine Theme Assume that algorithm A solves the decision clique problem Construct an algorithm A’ for solving the max clique problem that uses A as a subroutine

10
10 Example from divisor problem integer x, max, j; cin >> x; max = 1; for (j=2; j<x; j++) if (A(x,j))// using A as a procedure max = j; return max;

11
11 Problem 3 Connected graph problem –Input: Graph G = (V,E) list of nodes and edges –Yes/No Question: Is there a path of edges between every pair of nodes? Construct an algorithm to solve this problem

12
12 REC The class of solvable problems

13
13 Programs and Inputs Suppose we have a language L In order for P to solve the language recognition problem associated with L, what should P do on a given string x –P should halt after a finite amount of time –P should correctly respond yes/no with respect to “Is x in L?”

14
14 REC Formal Definition –A C ++ program P decides language L iff 1) Program P halts on all input strings 2) Program P correctly labels all strings it halts on as in or not in L. –A language L is recursive or decidable iff there exists a C ++ program P which decides L. What if there is a Java program P which decides L? –REC: the set of recursive languages

15
15 Church’s Thesis What is our modified Church’s Thesis? –Any algorithm can be written as a C ++ program –Any problem which cannot be solved by a C ++ program cannot be solved by any algorithm. Importance? –The definition of REC is robust. –We could use other models of computation Turing machines, Java programs, Lisp Programs,...

16
16 Languages REC Question: Is REC a proper subset of the set of all languages/problems?

17
17 Summary Solving problems –Subroutine theme REC –The class of solvable problems/languages –Church’s Thesis Specific model of computation is not important –Question: Are all problems solvable?

Similar presentations

© 2021 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google