Combinatorial Counting

Slides:



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

NP-Hard Nattee Niparnan.
Advanced Topics in Algorithms and Data Structures
CS774. Markov Random Field : Theory and Application Lecture 17 Kyomin Jung KAIST Nov
Introduction to Approximation Algorithms Lecture 12: Mar 1.
Is the following graph Hamiltonian- connected from vertex v? a). Yes b). No c). I have absolutely no idea v.
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)
MCS312: NP-completeness and Approximation Algorithms
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Computer Science Research for The Tree of Life Tandy Warnow Department of Computer Sciences University of Texas at Austin.
Chapter 15 Approximation Algorithm Introduction Basic Definition Difference Bounds Relative Performance Bounds Polynomial approximation Schemes Fully Polynomial.
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.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
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.
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.
CS 261 – Nov. 17 Graph properties – Bipartiteness – Isomorphic to another graph – Pseudograph, multigraph, subgraph Path Cycle – Hamiltonian – Euler.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
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.
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
Limitation of Computation Power – P, NP, and NP-complete
More NP-complete problems
NP-completeness Ch.34.
Chapter 10 NP-Complete Problems.
Depth-First Search N-Queens Problem Hamiltonian Circuits
Special Graphs By: Sandeep Tuli Astt. Prof. CSE.
Richard Anderson Lecture 26 NP-Completeness
Bipartite Matching Lecture 8: Oct 7.
Introduction to Discrete Mathematics
Some Great Theoretical Ideas in Computer Science for.
Richard Anderson Lecture 26 NP-Completeness
Hamiltonian Cycle and TSP
Hamiltonian Cycle and TSP
Hard Problems Introduction to NP
Chapter 5 Fundamental Concept
Hamiltonian Graphs Graphs Hubert Chan (Chapter 9.5)
BACKTRACKING- GENERAL METHOD
Week 11 - Monday CS221.
Algorithms for hard problems
What is the next line of the proof?
Great Theoretical Ideas in Computer Science
Exact Algorithms via Monotone Local Search
Special Graphs: Modeling and Algorithms
P and NP CISC4080, Computer Algorithms CIS, Fordham Univ.
Greedy Algorithms / Interval Scheduling Yin Tat Lee
Graphs: As a mathematics branch
Topological Sort (topological order)
Bipartite Matching and Other Graph Algorithms
Graphs Chapters 10.1 and 10.2 Based on slides by Y. Peng University of Maryland.
Graph Algorithm.
Lower Bound Theory.
Analysis and design of algorithm
Discrete Mathematics for Computer Science
ICS 353: Design and Analysis of Algorithms
Maximum Flows of Minimum Cost
Great Theoretical Ideas in Computer Science
CSE373: Data Structures & Algorithms Lecture 19: Spanning Trees
Chapter 11 Limitations of Algorithm Power
3. Brute Force Selection sort Brute-Force string matching
Counting Discrete Mathematics.
3. Brute Force Selection sort Brute-Force string matching
Backtracking and Branch-and-Bound
ICS 353: Design and Analysis of Algorithms
Special Graphs: Modeling and Algorithms
Concepts of Computation
CS 173, Lecture B Tandy Warnow
Mathematical Induction II
Lecture 24 Vertex Cover and Hamiltonian Cycle
3. Brute Force Selection sort Brute-Force string matching
Presentation transcript:

Combinatorial Counting Tandy Warnow

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 = {s1, s2, s3, …, sn} For i=1 up to n DO: Decide if you will include si Analysis: each subset is generated exactly once, and the number of ways to apply the algorithm is 2x2x…x2=2n.

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

Matching n boys and girls Algorithm: Let the boys be B1, B2, … Bn and let the girls be G1, G2, … Gn. For i=1 up to n DO Pick a girl for boy Bi, 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 {s1, s5, s3} 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 2n Number of k-subsets of n elements is n!/[k!(n-k)!] Number of k-colorings of a graph is kn

More advanced counting What is the number of k-subsets of a set S = {s1, s2, s3, … , sn} that do not include s1? What is the number of k-subsets of a set S = {s1, s2, s3, … , sn} that do include s1? What is the number of orderings of the set S in which s1 and s2 are not adjacent? What is the number of orderings of the set S in which s1 and s2 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 = {s1, s2, s3, … , sn} that do not include s1? Solution: same as number of k-subsets of {s2, s3, … , sn}. So (n-1)!/[(n-1-k)!k!]

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

Example What is the number of orderings of the set S in which s1 and s2 are adjacent? Solution: two cases: Case 1) s1 followed by s2 Case 2) s2 followed by s1 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 s1 and s2 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