1 / 17

Lecture 4

Lecture 4. Topics Problem solving Subroutine Theme REC language class The class of solvable problems Closure properties. Problem Solving. Solving problems In this course, we spend a lot of time proving there are unsolvable problems

ima
Download Presentation

Lecture 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. 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. 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 {vi | 1 <= i <= n} • E: Set of edges {(vi, vj)} • Clique: subset C of V such that there is an edge between all nodes in C

  5. Example v1 v2 v3 v6 v5 v4 V = {v1, v2, v3, v4, v5, v6} E = {(v1, v2), (v1, v5), (v1, v6), (v2, v3), (v2, v4), (v3, v4), (v4, v5), (v5, v6)} Question: How could we encode a graph as a string?

  6. Example 2 v1 v2 v3 v6 v5 v4 V = {v1, v2, v3, v4, v5, v6} E = { Max clique size? Smallest number of edges needed to increase m. c. size?

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

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

  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. 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. 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. REC The class of solvable problems

  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. REC • Formal Definition • A C++ program Pdecides 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. 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. REC Languages Question: Is REC a proper subset of the set of all languages/problems?

  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?

More Related