theory of computer science
play

Theory of Computer Science May 6, 2020 E1. Complexity Theory: - PowerPoint PPT Presentation

Theory of Computer Science May 6, 2020 E1. Complexity Theory: Motivation and Introduction Theory of Computer Science E1.1 Motivation E1. Complexity Theory: Motivation and Introduction E1.2 How to Measure Runtime? Gabriele R oger E1.3


  1. Theory of Computer Science May 6, 2020 — E1. Complexity Theory: Motivation and Introduction Theory of Computer Science E1.1 Motivation E1. Complexity Theory: Motivation and Introduction E1.2 How to Measure Runtime? Gabriele R¨ oger E1.3 Decision Problems University of Basel May 6, 2020 E1.4 Nondeterminism Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 1 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 2 / 38 Overview: Course Course Overview contents of this course: A. background � ⊲ mathematical foundations and proof techniques Background B. logic � Nondeterminism Logic ⊲ How can knowledge be represented? P, NP ⊲ How can reasoning be automated? Automata Theory Theory C. automata theory and formal languages � Polynomial Reductions Turing Computability ⊲ What is a computation? Cook-Levin Theorem D. Turing computability � Complexity ⊲ What can be computed at all? NP-complete Problems More Computability E. complexity theory ⊲ What can be computed efficiently? F. more computability theory ⊲ Other models of computability Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 3 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 4 / 38

  2. E1. Complexity Theory: Motivation and Introduction Motivation E1. Complexity Theory: Motivation and Introduction Motivation A Scenario (1) Example Scenario ◮ You are a programmer at a logistics company. E1.1 Motivation ◮ Your boss gives you the task of developing a program to optimize the route of a delivery truck: ◮ The truck begins its route at the company depot. ◮ It has to visit 50 stops. ◮ You know the distances between all relevant locations (stops and depot). ◮ Your program should compute a tour visiting all stops and returning to the depot on a shortest route. Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 5 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 6 / 38 E1. Complexity Theory: Motivation and Introduction Motivation E1. Complexity Theory: Motivation and Introduction Motivation A Scenario (2) What You Don’t Want to Say Example Scenario (ctd.) ◮ You work on the problem for weeks, but you do not manage to complete the task. ◮ All of your attempted programs ◮ compute routes that are possibly suboptimal, or ◮ do not terminate in reasonable time (say: within a month). ◮ What do you say to your boss? “I can’t find an efficient algorithm, I guess I’m just too dumb.” Source: M. Garey & D. Johnson, Computers and Intractability, Freeman 1979, p. 2 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 7 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 8 / 38

  3. E1. Complexity Theory: Motivation and Introduction Motivation E1. Complexity Theory: Motivation and Introduction Motivation What You Would Like to Say What Complexity Theory Allows You to Say “I can’t find an efficient algorithm, “I can’t find an efficient algorithm, because no such algorithm is possible!” but neither can all these famous people.” Source: M. Garey & D. Johnson, Computers and Intractability, Freeman 1979, p. 2 Source: M. Garey & D. Johnson, Computers and Intractability, Freeman 1979, p. 3 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 9 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 10 / 38 E1. Complexity Theory: Motivation and Introduction Motivation E1. Complexity Theory: Motivation and Introduction Motivation Why Complexity Theory? Why Reductions? Complexity Theory Reductions Complexity theory tells us which problems An important part of complexity theory are can be solved quickly (“simple problems”) (polynomial) reductions that show how a given problem P and which ones cannot (“hard problems”). can be reduced to another problem Q . German: Komplexit¨ atstheorie German: Reduktionen ◮ This is useful in practice because simple and hard problems ◮ useful for theoretical analysis of P and Q because require different techniques to solve. it allows us to transfer our knowledge between them ◮ If we can show that a problem is hard we do not need to waste ◮ often also useful for practical algorithms for P : reduce P to Q and then use the best known algorithm for Q our time with the (futile) search for a “simple” algorithm. Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 11 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 12 / 38

  4. E1. Complexity Theory: Motivation and Introduction Motivation E1. Complexity Theory: Motivation and Introduction Motivation Test Your Intuition! (1) Test Your Intuition! (2) 1 Find a simple path (= without cycle) from u ∈ V to v ∈ V with minimal length. ◮ The following slide lists some graph problems. 2 Find a simple path (= without cycle) ◮ The input is always a directed graph G = � V , E � . from u ∈ V to v ∈ V with maximal length. ◮ How difficult are the problems in your opinion? 3 Determine whether G is strongly connected ◮ Sort the problems (every node is reachable from every other node). from easiest (= requires least amount of time to solve) 4 Find a cycle (non-empty path from u to u for any u ∈ V ; to hardest (= requires most time to solve) multiple visits of nodes are allowed). ◮ no justification necessary, just follow your intuition! 5 Find a cycle that visits all nodes. ◮ anonymous and not graded 6 Find a cycle that visits a given node u . 7 Find a path that visits all nodes without repeating a node. 8 Find a path that uses all edges without repeating an edge. Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 13 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 14 / 38 E1. Complexity Theory: Motivation and Introduction How to Measure Runtime? E1. Complexity Theory: Motivation and Introduction How to Measure Runtime? How to Measure Runtime? E1.2 How to Measure Runtime? ◮ Time complexity is a way to measure how much time it takes to solve a problem. ◮ How can we define such a measure appropriately? German: Zeitkomplexit¨ at/Zeitaufwand Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 15 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 16 / 38

  5. E1. Complexity Theory: Motivation and Introduction How to Measure Runtime? E1. Complexity Theory: Motivation and Introduction How to Measure Runtime? Example Statements about Runtime Precise Statements vs. General Statements Example Statement about Runtime “Running sort /usr/share/dict/words Example statements about runtime: on the computer dakar takes 0.035 seconds.” ◮ “Running sort /usr/share/dict/words on the computer dakar takes 0.035 seconds.” advantage: very precise ◮ “With a 1 MiB input file, sort takes at most 1 second on a modern computer.” disadvantage: not general ◮ “Quicksort is faster than sorting by insertion.” ◮ input-specific: ◮ “Sorting by insertion is slow.” What if we want to sort other files? ◮ machine-specific: � Very different statements with different pros and cons. What happens on a different computer? ◮ even situation-specific: Will we get the same result tomorrow that we got today? Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 17 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 18 / 38 E1. Complexity Theory: Motivation and Introduction How to Measure Runtime? E1. Complexity Theory: Motivation and Introduction How to Measure Runtime? General Statements about Runtime General Statements about Runtime In this course we want to make general statements In this course we want to make general statements about runtime. We accomplish this in three ways: about runtime. We accomplish this in three ways: 1. General Inputs 2. Ignoring Details Instead of concrete inputs, we talk about general types of input: Instead of exact formulas for the runtime we specify the order of magnitude: ◮ Example: runtime to sort an input of size n ◮ Example: instead of saying that we need time in the worst case ⌈ 1 . 2 n log n ⌉ − 4 n + 100, we say that we need time O ( n log n ). ◮ Example: runtime to sort an input of size n ◮ Example: instead of saying that we need time O ( n log n ), in the average case O ( n 2 ) or O ( n 4 ), we say that we need polynomial time. here: runtime for input size n in the worst case here: What can be computed in polynomial time? Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 19 / 38 Gabriele R¨ oger (University of Basel) Theory of Computer Science May 6, 2020 20 / 38

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend