CS 173, Lecture B Tandy Warnow. Topics for today Reminder about Examlet on Tuesday My office hours next week: –Tuesday 2-3 PM and Thursday 3-4 PM Office.

Slides:



Advertisements
Similar presentations
CS 336 March 19, 2012 Tandy Warnow.
Advertisements

Great Theoretical Ideas in Computer Science
NP-Hard Nattee Niparnan.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Limitation of Computation Power – P, NP, and NP-complete
Advanced Topics in Algorithms and Data Structures
What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
Great Theoretical Ideas in Computer Science for Some.
CS774. Markov Random Field : Theory and Application Lecture 17 Kyomin Jung KAIST Nov
Great Theoretical Ideas in Computer Science.
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Introduction to Approximation Algorithms Lecture 12: Mar 1.
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
NP-Complete Problems Problems in Computer Science are classified into
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
Ch 13 – Backtracking + Branch-and-Bound
Vertex cover problem S  V such that for every {u,v}  E u  S or v  S (or both)
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Lecture 6 Jianjun Hu Department of Computer Science and Engineering University of South Carolina CSCE350 Algorithms and Data Structure.
MCS312: NP-completeness and Approximation Algorithms
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Combinatorial Algorithms Reference Text: Kreher and Stinson.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
CSE332: Data Abstractions Lecture 24.5: Interlude on Intractability Dan Grossman Spring 2012.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
NP-Complete problems.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
LIMITATIONS OF ALGORITHM POWER
Algorithms for hard problems Introduction Juris Viksna, 2015.
CSC 413/513: Intro to Algorithms
Lecture 19 Minimal Spanning Trees CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
CS 261 – Nov. 17 Graph properties – Bipartiteness – Isomorphic to another graph – Pseudograph, multigraph, subgraph Path Cycle – Hamiltonian – Euler.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
Introduction to NP Instructor: Neelima Gupta 1.
Models of Greedy Algorithms for Graph Problems Sashka Davis, UCSD Russell Impagliazzo, UCSD SIAM SODA 2004.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
Ch3 /Lecture #4 Brute Force and Exhaustive Search 1.
Exhaustive search Exhaustive search is simply a brute- force approach to combinatorial problems. It suggests generating each and every element of the problem.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Limitation of Computation Power – P, NP, and NP-complete
More NP-complete problems
NP-completeness Ch.34.
Chapter 10 NP-Complete Problems.
Combinatorial Counting
Introduction to Approximation Algorithms
Algorithms for hard problems
Exact Algorithms via Monotone Local Search
Bipartite Matching and Other Graph Algorithms
Analysis and design of algorithm
ICS 353: Design and Analysis of Algorithms
Objective of This Course
Maximum Flows of Minimum Cost
Chapter 11 Limitations of Algorithm Power
Graphs and Algorithms (2MMD30)
Richard Anderson Lecture 26 NP-Completeness
Lecture 11 CSE 331 Sep 23, 2011.
Special Graphs: Modeling and Algorithms
CS 173, Lecture B Tandy Warnow
Presentation transcript:

CS 173, Lecture B Tandy Warnow

Topics for today Reminder about Examlet on Tuesday My office hours next week: –Tuesday 2-3 PM and Thursday 3-4 PM Office hours after next week will be based on response to poll sent via Piazza Basics of combinatorial counting

Examlet One problem about Dynamic Programming Several problems about big-oh One problem about counting

Examlet Give a Dynamic Programming algorithm for one of the following: –A two-person game –The longest increasing subsequence –Determine if you can make change for n cents using coins (e.g., 3-, 5-, and 7-cent coins)

Examlet Big-oh –Know the definition! (Exists constants…) –Be able to find the constants to establish that f is O(g) –Be able to quickly figure out whether one function is big-oh of another

Examlet Counting –One problem that will require you to be able to count something, using basic techniques –Know the basic techniques –Know the basic formulas C(n,k) P(n,k) The number of functions from A to B

Using combinatorial counting Evaluating exhaustive search strategies: –Finding maximum clique –Determining if a graph has a 3-coloring –Finding a maximum matching in a graph –Determining if a graph has a Hamiltonial cycle or an Eulerian graph

Combinatorial counting How many ways can you put n items in a row? pick k items out of n? pick subsets of a set of size n? assign k colors to the vertices of a graph? match up n boys and n girls?

Technique To count the number of objects, design an algorithm to generate the entire set of objects. Check if each object is created exactly once (if not, you will have to do a correction later). The algorithm’s output can be seen as the leaves of a decision tree, and you can just count the leaves.

Putting n items in a row Algorithm for generating all the possibilities: For i=1 up to n, DO –Pick an item from S to go in position i –Delete that item from the set S Analysis: each way of completing this generates a different list. The number of ways of performing this algorithm is n!

Number of subsets of a set of size n Algorithm to generate the subsets of a set S = {s 1, s 2, s 3, …, s n } For i=1 up to n DO: –Decide if you will include s i Analysis: each subset is generated exactly once, and the number of ways to apply the algorithm is 2x2x…x2=2 n.

k-coloring a graph Let G have vertices v 1, v 2, v 3, …, v n Algorithm to k-color the vertices: For i=1 up to n DO: –Pick a color for vertex v i Analysis: each coloring is produced exactly once, and there are k n ways of applying the algorithm.

Matching n boys and girls Algorithm: Let the boys be B 1, B 2, … B n and let the girls be G 1, G 2, … G n. For i=1 up to n DO –Pick a girl for boy B i, and remove her from the set Analysis: there are n ways to pick the first girl, n-1 ways to pick the second girl, etc., and each way produces a different matching. Total: n!

Picking k items out of n Algorithm for generating all the possibilities: For i=1 up to k, DO –Pick an item from S to include in set A –Delete that item from the set S The number of ways of performing this algorithm is n(n-1)(n-2)…(n-k+1)=n!/(n-k)! But each set A can be generated in multiple ways - and we have overcounted!

Fixing the overcounting Each set A of k elements is obtained through k! ways of running the algorithm. As an example, we can generate {s 1, s 5, s 3 } in 6 ways, depending upon the order in which we pick each of the three elements. So the number of different sets is the number of ways of running the algorithm, divided by k!. The solution is n!/[k!(n-k)!]

Summary (so far) To count the number of objects, design an algorithm to generate the entire set of objects. Check if each object is created exactly once (if not, you will have to do a correction later). The algorithm’s output can be seen as the leaves of a decision tree, and you can just count the leaves.

Summary Number of orderings of n elements is n! Number of subsets of n elements is 2 n Number of k-subsets of n elements is n!/[k!(n-k)!] Number of k-colorings of a graph is k n

More advanced counting What is the number of k-subsets of a set S = {s 1, s 2, s 3, …, s n } that do not include s 1 ? What is the number of k-subsets of a set S = {s 1, s 2, s 3, …, s n } that do include s 1 ? What is the number of orderings of the set S in which s 1 and s 2 are not adjacent? What is the number of orderings of the set S in which s 1 and s 2 are adjacent?

New techniques Count the complement Divide into disjoint cases, and count each case

Example What is the number of k-subsets of a set S = {s 1, s 2, s 3, …, s n } that do not include s 1 ? Solution: same as number of k-subsets of {s 2, s 3, …, s n }. So (n-1)!/[(n-1-k)!k!]

Example What is the number of k-subsets of a set S = {s 1, s 2, s 3, …, s n } that do include s 1 ? Solution: same as the number of (k-1)- subsets of {s 2, s 3, …, s n }, so (n-1)!/[(n-k)!(k-1)!]

Example What is the number of orderings of the set S in which s 1 and s 2 are adjacent? Solution: two cases: –Case 1) s 1 followed by s 2 –Case 2) s 2 followed by s 1 Same number of each type. Easy to see that there are (n-1)! of each type, so 2(n-1)! in total

Example Number of orderings of the set S in which s 1 and s 2 are not adjacent? This is the same as n!-2(n-1)!

Using combinatorial counting Evaluating exhaustive search strategies: –Finding maximum clique –Determining if a graph has a 3-coloring –Finding a maximum matching in a graph –Determining if a graph has a Hamiltonian cycle or an Eulerian tour