Combinatorics.

Slides:



Advertisements
Similar presentations
CSCE 2100: Computing Foundations 1 Combinatorics Tamara Schneider Summer 2013.
Advertisements

Recursion. n! (n factorial)  The number of ways n objects can be permuted (arranged).  For example, consider 3 things, A, B, and C.  3! = 6 1.ABC 2.ACB.
Multiplication Rule. A tree structure is a useful tool for keeping systematic track of all possibilities in situations in which events happen in order.
Quit Permutations Combinations Pascal’s triangle Binomial Theorem.
CSE115/ENGR160 Discrete Mathematics 04/17/12
CSE 321 Discrete Structures Winter 2008 Lecture 16 Counting.
Slides prepared by Rose Williams, Binghamton University Chapter 11 Recursion.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
Recurrence Relations Connection to recursive algorithms Techniques for solving them.
Sequences and Series. Quick Review.
P ERMUTATIONS AND C OMBINATIONS Homework: Permutation and Combinations WS.
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Topics to be covered: Produce all combinations and permutations of sets. Calculate the number of combinations and permutations of sets of m items taken.
Analyzing Complexity of Lists OperationSorted Array Sorted Linked List Unsorted Array Unsorted Linked List Search( L, x ) O(logn) O( n ) O( n ) Insert(
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
March 10, 2015Applied Discrete Mathematics Week 6: Counting 1 Permutations and Combinations How many different sets of 3 people can we pick from a group.
Binomial Expansion Honors Advanced Algebra Presentation 2-3.
Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1.
Combinatorics University of Akron Programming Team 9/23/2011.
1 CS 140 Discrete Mathematics Combinatorics And Review Notes.
Lesson 0.4 (Counting Techniques)
Counting Techniques Tree Diagram Multiplication Rule Permutations Combinations.
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
1 Section 5.3 Permutations and Combinations Permutations (order counts) A permutation of a set is an arrangement of the objects from a set. There are n!
Combinatorics. What is Combinatorics? Wide ranging field involving the study of discrete objects.
CS1022 Computer Programming & Principles
The Multiplication Rule
Permutations and Combinations
L14: Permutations, Combinations and Some Review
The Pigeonhole Principle
Elementary Probability Theory
Developing Your Counting Muscles
CSE15 Discrete Mathematics 04/19/17
ICS 253: Discrete Structures I
CSC-2259 Discrete Structures
Mathematical Preliminaries
COCS DISCRETE STRUCTURES
More Simple Recursive Problems
Counting Techniuqes.
Mathematical Induction Recursion
Combinatorics.
A Brief Summary for Exam 2
COUNTING AND PROBABILITY
Binomial Identities.
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Pascal's Triangle This is the start of Pascal's triangle. It follows a pattern, do you know.
CS201: Data Structures and Discrete Mathematics I
Basic Counting.
Lesson 11-1 Permutations and Combinations
Permutations and Combinations
Binomial Identities.
Combinatorics.
CS 250, Discrete Structures, Fall 2011 Nitesh Saxena
CSE 321 Discrete Structures
Recursion.
Permutations and Combinations
Recreational Exponentiation
Counting Discrete Mathematics.
Basic Counting Lecture 9: Nov 5, 6.
Permutations and Combinations
Michael Duquette & Whitney Sherman
CS 250, Discrete Structures, Fall 2014 Nitesh Saxena
Combinatorics.
Introduction to Discrete Mathematics
Last Week We are going to count: The Art of Combinatorics
Chapter 7 Advanced Counting Techniques
Permutations and Combinations
Permutations and Combinations
Recursion: The Mirrors
Presentation transcript:

Combinatorics

Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures In the past, ad-hoc solutions were available. Now, ....

Counting Techniques product rule sum rule Inclusion-Exclusion Formula 5 shirts * 4 pants = total 20 combinations sum rule if any one is missing from the closet, it is one of 9 clothing pieces Inclusion-Exclusion Formula |A  B| = |A| + |B| - |A  B| |A  B  C | = |A| + |B| + |C| - |A  B| - |B  C| - |B  C| + |A  B  B | eliminates double counting Bijection map a member of a set to a member of target set that is to be counted

More counting techniques Permutation an arrangement of n items where every item appears exactly once - n!=∏ni=1 i arrange three letters word using a, b, c abc, acb, bac, bca, cab, cba, - 6 words (3!) what if letters are reused? (strings) aaa, abb, ... - n∏r= nr Subsets there are 2n subsets of n items a, b, c, ab, bc, ac, abc, and an empty set – 8 subsets

Recurrence Relations Recursively defined structures tree, list, WFF, ... divide conquer algorithms work on them recurrence relation polynomials an = an-1 + 1, a1=1  an = n exponential an = 2an-1, a1=2  an = 2n factorial an = nan-1, a1=1  an = n!

Binomial Coefficient nCk - choose k things out of n easy one how many ways to form a k-member committee from n people Paths across a grid of n X m

Binomial Coefficient (2) coefficient of (a+b)n what is the coeff of akbn-k ? how many ways to choose k a-terms out of n (a + b)3 = 1a3 + 3a2b + 3ab2 + 1b3 (a + b)3 = aaa + 3aab + 3abb + bbb

Pascal’s Triangle prove that nCk = (n-1)C(k-1) + (n-1)Ck Sum=2n 1 2 4 8 16 32 n=0 n=1 n=2 n=3 n=4 n=5 4C3 = 3C2 + 3C3 4C0 4C1 4C2 4C3 4C4 prove that nCk = (n-1)C(k-1) + (n-1)Ck

Binomial Coefficient(3) k n! (n-k)!k! = (n-k)!k! can cause overflow nCk = (n-1)C(k-1) + (n-1)Ck k 1 2 3 n-1 n … … case1: this is included same as choosing k-1 from n-1 case2: not must choose k from n-1

Stop the recurrence good ending points nCk = (n-1)C(k-1) + (n-1)Ck nC1 = n nCn = 1

safeness time complexity what about 3C0, 2C5, (-3)C5 int bc(int n, int k) { if (k == 1) return(n); return bc(n-1, k-1) + bc(n-1, k); } nCk = (n-1)C(k-1) + (n-1)Ck safeness what about 3C0, 2C5, (-3)C5 don’t we need else part? time complexity one comparison and one addition (let it be C1) let recursion overhead be C2 T(n, k) = T(n-1, k-1) + T(n-1, k) + C1 + C2

Finonacci Numbers F0 = 0 F1 = 1 Fn = Fn-1 + Fn-2 for n  2 int fb(int n) { if (n < 0) ???? if (n < 2)) return(n); // f(0) =0, f(1) = 1 else return fb(n-1) + fb(n-2); }

Eulerian Numbers the number of permutations of the numbers 1 to n in which exactly m elements are greater than the previous element review Stirling Numbers, Partitions

Induction prove/disprove that Tn=2n-1 n … Tn Tn = 2Tn-1 + 1, T0=0 1 2 1 2 3 4 5 6 7 … Tn 15 31 63 127 prove/disprove that Tn=2n-1

How Many Pieces of Land (i - 1) * i * (i * i - 5 * i + 18) / 24 + 1 Let P(n) be the number of lands when n points are drawn on circle  Now assume knowing P(n-1), want to know P(n) by adding the n-th point  when the n-th point draw a line to the k-th point (1 <= k <= n-1)  on the LHS on k-th point, there is k-1 points between k-th and n-th point  on the RHS on k-th point, there is (n-1)-k+1 points between k-th and n-th point  the points in these 2 sets(LHS, RHS) are completely connected,  so there are (k-1)*(n-k) lines crossed by the newly drawn line,  creating (k-1)*(n-k)+1 new lands......  So, drawing lines from newly added n-th point to all n-1 old points,  will create  summation[(k-1)(j-k)+1] {k = 1..j (j = n-1)} new lands  let says the summation be F(j)  P(n)= P(n-1) + F(n-1)  = P(n-2) + F(n-2) + F(n-1)  .....  = P(0) + F(1) + F(2) + ....... + F(n-1)  = 1 + summation(F(i)) {i = 1..n-1}  by using formula of summation to simplify the equatoin(what a difficult job.....)  I get  answer = (i - 1) * i * (i * i - 5 * i + 18) / 24 + 1;  (i - 1) * i * (i * i - 5 * i + 18) / 24 + 1

Tower of Hanoi