Counting. Andreas Klappenecker

Similar documents
CS228 - Basic Counting and the Pigeonhole Principle

It is important that you show your work. There are 134 points available on this test.

Counting: Basics. Rosen, Chapter 6.1

Counting: Basics. A simple counting problem. Counting: the product rule. Relation to Cartesian products. Relation to Cartesian products

Introduction. CS243: Discrete Structures. Combinatorics. Product Rule. Basic Counting Rules. Example 2. Example 1

Counting Product Rule

Basic Counting Principles: The Product Rule

Solution : a) C(18, 1)C(325, 1) = 5850 b) C(18, 1) + C(325, 1) = 343

Solutions to In Class Problems Week 9, Fri.

Functions 2/1/2017. Exercises. Exercises. Exercises. and the following mathematical appetizer is about. Functions. Functions

9.5 Equivalence Relations

Counting. Rosen, Chapter 6 Walls and Mirrors, Chapter 3

Counting Pigeonhole principle

Functions. How is this definition written in symbolic logic notation?

Section 6.3: Further Rules for Counting Sets

CHAPTER 8. Copyright Cengage Learning. All rights reserved.

Cantor s Diagonal Argument for Different Levels of Infinity

Graph Theory Questions from Past Papers

Math 3336 Section 6.1 The Basics of Counting The Product Rule The Sum Rule The Subtraction Rule The Division Rule

Notes for Recitation 13

Discrete Structures Lecture The Basics of Counting

PACKING DIGRAPHS WITH DIRECTED CLOSED TRAILS

Comparing sizes of sets

Midterm 2 Solutions. CS70 Discrete Mathematics and Probability Theory, Spring 2009

Table 1 below illustrates the construction for the case of 11 integers selected from 20.

3. Determine whether f is a function from the set of all bit strings to the set of integers if

CPS 102: Discrete Mathematics. Quiz 3 Date: Wednesday November 30, Instructor: Bruce Maggs NAME: Prob # Score. Total 60

Functions. Prof. Susan Older. 20 October (CIS 375) Functions 20 Oct / 14

Math Summer 2012

2SAT Andreas Klappenecker

Line Graphs and Circulants

Chapter 3. Set Theory. 3.1 What is a Set?

Recursion and Structural Induction

COUNTING AND PROBABILITY

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Generell Topologi. Richard Williamson. May 6, 2013

Solutions to First Exam, Math 170, Section 002 Spring 2012

Discrete mathematics , Fall Instructor: prof. János Pach

CSE 215: Foundations of Computer Science Recitation Exercises Set #4 Stony Brook University. Name: ID#: Section #: Score: / 4

2 A topological interlude

Announcements. Problem Set 3 due Friday, October 21. Alternate Midterm Times. Drop by office hours! Ask questions at

CHAPTER 2. Graphs. 1. Introduction to Graphs and Graph Isomorphism

Topology Homework 3. Section Section 3.3. Samuel Otten

CSCI FOUNDATIONS OF COMPUTER SCIENCE

Computer Algorithms-2 Prof. Dr. Shashank K. Mehta Department of Computer Science and Engineering Indian Institute of Technology, Kanpur

Math 202 Test Problem Solving, Sets, and Whole Numbers 19 September, 2008

Discrete Structures. Fall Homework3

r=1 The Binomial Theorem. 4 MA095/98G Revision

13 th Annual Johns Hopkins Math Tournament Saturday, February 19, 2011 Automata Theory EUR solutions

The Resolution Algorithm

arxiv: v2 [math.co] 13 Aug 2013

2009 HMMT Team Round. Writing proofs. Misha Lavrov. ARML Practice 3/2/2014

Assignment 4 Solutions of graph problems

1. Chapter 1, # 1: Prove that for all sets A, B, C, the formula

An Improved Upper Bound for the Sum-free Subset Constant

Lecture 10. Sequence alignments

5 Graphs

Complexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np

COUNTING THE NUMBER OF WINNING BINARY STRINGS IN THE 1-DIMENSIONAL SAME GAME. Department of Mathematics Oberlin College Oberlin OH 44074

2. Functions, sets, countability and uncountability. Let A, B be sets (often, in this module, subsets of R).

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

Extremal Graph Theory: Turán s Theorem

THEORY OF COMPUTATION

Functions. Def. Let A and B be sets. A function f from A to B is an assignment of exactly one element of B to each element of A.

Slides for Faculty Oxford University Press All rights reserved.

CHENNAI MATHEMATICAL INSTITUTE M.Sc. / Ph.D. Programme in Computer Science

Discrete Mathematics Lecture 4. Harper Langston New York University

Solutions to Homework 10

Topology 550A Homework 3, Week 3 (Corrections: February 22, 2012)

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

Lamé s Theorem. Strings. Recursively Defined Sets and Structures. Recursively Defined Sets and Structures

EDAA40 At home exercises 1

ASSIGNMENT 4 SOLUTIONS

MATH 363 Final Wednesday, April 28. Final exam. You may use lemmas and theorems that were proven in class and on assignments unless stated otherwise.

HW 1 CMSC 452. Morally DUE Feb 7 NOTE- THIS HW IS THREE PAGES LONG!!! SOLUTIONS THROUGOUT THIS HW YOU CAN ASSUME:

Discrete Mathematics Exam File Fall Exam #1

Math Circle Beginners Group October 18, 2015 Solutions

On the packing chromatic number of some lattices

MATH 54 - LECTURE 4 DAN CRYTSER

Introduction to Modular Arithmetic

Improved upper and lower bounds on the feedback vertex numbers of grids and butterflies

6c Lecture 3 & 4: April 8 & 10, 2014

Propositional Logic. Andreas Klappenecker

2 The Fractional Chromatic Gap

MATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).

ELEMENTARY NUMBER THEORY AND METHODS OF PROOF

CSC Discrete Math I, Spring Sets

Combinatorial Gems. Po-Shen Loh. June 2009

QED Q: Why is it called the triangle inequality? A: Analogue with euclidean distance in the plane: picture Defn: Minimum Distance of a code C:

THE FUNDAMENTAL GROUP AND THE BROUWER FIXED POINT THEOREM

CME 305: Discrete Mathematics and Algorithms Instructor: Reza Zadeh HW#3 Due at the beginning of class Thursday 02/26/15

or else take their intersection. Now define

Bijective Proofs of Two Broken Circuit Theorems

in this web service Cambridge University Press

2/18/14. Uses for Discrete Math in Computer Science. What is discrete? Why Study Discrete Math? Sets and Functions (Rosen, Sections 2.1,2.2, 2.

CHAPTER 7. Copyright Cengage Learning. All rights reserved.

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

Pebble Sets in Convex Polygons

Hashing. Yufei Tao. Department of Computer Science and Engineering Chinese University of Hong Kong

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

Transcription:

Counting Andreas Klappenecker

Counting k = 0; for(int i=1; i<=m; i++) { for(int j=1; j<=n; j++) { k = k+1; } } // What is the value of k? Answer: k=mn

Product Rule Suppose that a procedure can be broken down into a sequence of two tasks. If there are m ways to do the first task and for each of these ways there are n ways to do the second task, then there are mn ways to do the procedure.

Bit Strings How many bit strings of length seven are there? Answer: Each of the seven bits can be chosen in 2 ways. Therefore, there is a total of 2 7 = 128 different bit strings of length 7 by the product rule.

Number of Functions Suppose that f: A -> B is a function from a set A with m elements to a set B with n elements. How many such functions exist? Answer: For each argument, we can choose one of the n elements of the codomain. Therefore, by the product rule, we have n x n x... x n = n m functions.

Number of Injective Functions Recall that a function f is injective if and only if its function values f(a) and f(b) are different whenever the arguments a and b are different. Thus, all function values of an injective function are different. How many injective functions are there from a set A with m elements to a set B with n elements? <Try to figure it out before we answer it on the next slide>

Number of Injective Functions Case A > B. There are no injective functions from A to B, as one cannot choose all function values to be different. Case A <= B. Suppose that A = {a 1, a 2,...,a m } and n= B. The value of a 1 can be chosen in n different ways. The value of a 2 can be chosen in n-1 different ways, as the value f(a 1 ) cannot be used again. In general, after values of {a 1,..., a k-1 } have been chosen, the value of a k can be chosen in just n-(n-1) = n-k+1 ways. Thus, by the product rule there are n(n-1)...(n-m+1) injective functions from A to B.

Sum Rule Suppose that S is a disjoint union of two finite sets A and B. Recall that S denotes the size (cardinality) of the set. The sum rule says that S = A + B.

Counting k = 0; for(int i=1; i<=m; i++) k = k+1; // First loop completed for(int j=1; j<=n; j++) k = k+1; // What is the value of k? k=m+n

Counting Principles Counting is based on simple rules such as the sum and product rules. By themselves, they are trivial. These rules are typically used in a combination. The hardest part is to figure out a good strategy to count elements.

Example Each user on a computer system has a password which is 6-8 characters long, where each character is an uppercase letter or a digit. Each password must contain at least one digit. How many possible passwords are there? Let P be the number of passwords, P k the number of passwords of length k. Hence, P = P 6 + P 7 + P 8. Now, P k = 36 k - 26 k = number of strings of length k with digits or uppercase letters - number of strings that just contain letters. Hence, P = P 6 + P 7 + P 8 = 36 6-26 6 + 36 7-26 7 + 36 8-26 8

Inclusion-Exclusion Formula Let A and B be finite sets. A B = A + B - A B

Inclusion-Exclusion Example How many bit strings of length 8 either start with 1 or end with 00? Let A be the set of bit strings of length 8 that start with 1. Then A = 2 7. Let B the bit strings of length 8 that end with 00. Then B = 2 6. The A B = bit strings of length 8 starting with 1 and ending with 00 = 2 5. Therefore, A B = A + B - A B = 2 7 + 2 6-2 5

Pigeonhole Principle If k is a positive integer and k+1 or more objects are placed into k boxes, then there is at least one box containing two or more objects.

Pigeonhole Principle: Example 1 Among any 367 people, there must be at least two with the same birthday. [There are at most 366 possible birthdays]

Pigeonhole Principle: Example 2 For every positive integer n there is a multiple of n containing only 0s and 1s in its decimal expansion. Proof: Consider the n+1 integers 1, 11,..., 11...1 (with n+1 ones) There are n possible remainders when these integers are divided by n, so two must have the same remainder. The larger minus the smaller of the two numbers is a multiple of n, which has a decimal expansion consisting entirely of 0s and 1s.

Pigeonhole Principle: Example 3 Among any N positive integers, there exists 2 whose difference is divisible by N-1. Proof: Let a 1, a 2,..., a N be the numbers. For each a i, let r i be the remainder that results from dividing a i by N - 1. (So r i = a i mod (N-1) and r i can take on only the values 0, 1,..., N-2.) There are N-1 possible values for each r i, but there are N r i 's. Thus, by the pigeon hole principle, there must be two of the ri's that are the same, r j = r k for some pair j and k But then, the corresponding a i 's have the same remainder when divided by N-1, and so their difference a j - a k is evenly divisible by N-1.

Sequences Let S = (a 1,...,a m ) be a sequence of numbers. A subsequence of S is obtained by deleting terms of the sequence S, but keeping the order among the elements. Example: (5,4,7,1,3,2) contains subsequences (5,4,3,2) and (5,7) A sequence is called strictly decreasing if each term is smaller than the previous one. A sequence is called strictly increasing if each term is larger than the previous one.

Sequences (2) Every sequence of n 2 +1 distinct real numbers contains a subsequence of length n+1 that is either strictly increasing or strictly decreasing. [ A proof by contradiction seems like a good choice. But how can we arrive at a contradiction?]

Sequences (3) Seeking a contradiction, we assume that there exists a sequence S= (a 1,...,a n**2-1 ) does not contain any strictly increasing (or decreasing) subsequence of length n+1 or longer. Associate with each term a k of the sequence two integers: i k = length of the longest increasing subsequence starting at a k d k = length of the longest decreasing subsequence starting at a k Notice that 1 <= i k, d k <= n, so there are n 2 distinct ordered pairs (i k, d k ) but the sequence contains n 2 +1 elements, so there must be two terms of a s and a t of the sequence that contain the same pairs. We will show that this is impossible.

Sequence (4) Since all elements of the sequence are distinct real numbers, we either have a s < a t or a s > a t. If a s < a t then a strictly increasing subsequence of length i s +1 can be formed by taking a s followed by the strictly increasing subsequence of S starting at a t, contradicting the fact that i s denote the length of the longest strictly increasing subsequence starting at a s. Similarly, if a s > a t then a strictly decreasing subsequence of length i s +1 starting at a s can be formed, contradicting the definition of i s. Therefore, such a sequence S cannot exist.