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

Similar documents
Counting: Basics. Rosen, Chapter 6.1

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

CS228 - Basic Counting and the Pigeonhole Principle

Counting Product Rule

Basic Counting Principles: The Product Rule

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

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

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

Counting. Andreas Klappenecker

Sets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Sets Fall / 31

Notes for Recitation 13

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

Ma/CS 6b Class 12: Ramsey Theory

Solutions to In Class Problems Week 9, Fri.

Ma/CS 6b Class 10: Ramsey Theory

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

CSCI FOUNDATIONS OF COMPUTER SCIENCE

COMP Logic for Computer Scientists. Lecture 17

Math 55 - Spring Lecture notes # 14 - March 9 (Tuesday)

CSE 312 Foundations II. 2. Counting. Winter 2017 W.L. Ruzzo

Recursion: The Mirrors. (Walls & Mirrors - Chapter 2)

Inductive Data Types

2.1 Sets 2.2 Set Operations

Counting Pigeonhole principle

Discrete Structures Lecture The Basics of Counting

SETS. Sets are of two sorts: finite infinite A system of sets is a set, whose elements are again sets.

Sets 1. The things in a set are called the elements of it. If x is an element of the set S, we say

Discrete Structures for Computer Science

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

Lecture 25 : Counting DRAFT

Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets

1.1 - Introduction to Sets

SET DEFINITION 1 elements members

HOMEWORK #4 SOLUTIONS - MATH 4160

Lecture 6,

Problem Set 7 Solutions

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Discrete Mathematics

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

1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall

STUDENT NUMBER: MATH Final Exam. Lakehead University. April 13, Dr. Adam Van Tuyl

The Further Mathematics Support Programme

To illustrate what is intended the following are three write ups by students. Diagonalization

ELEC-270 Solutions to Assignment 5

Recursively Defined Functions

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

CSE 20 DISCRETE MATH WINTER

Problem Y A limit 1 second. Zigzag

Outline. CISC 1100/1400 Structures of Comp. Sci./Discrete Structures Chapter 1 Sets. Sets. Enumerating the elements of a set

Fall 2018 September 18, Written Homework 02

Math 110 FOUNDATIONS OF THE REAL NUMBER SYSTEM FOR ELEMENTARY AND MIDDLE SCHOOL TEACHERS

2 Review of Set Theory

1 Sets, Fields, and Events

Today s Topics. What is a set?

Randomized Algorithms, Hash Functions


Relational Database: The Relational Data Model; Operations on Database Relations

Set and Set Operations

What is Set? Set Theory. Notation. Venn Diagram

LESSON 1: INTRODUCTION TO COUNTING

Chapter 2: Sets. Diana Pell. In the roster method: elements are listed between braces, with commas between the elements

c) the set of students at your school who either are sophomores or are taking discrete mathematics

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

Figure 1: From Left to Right, General Venn Diagrams for One, Two, and Three Sets

Encoding/Decoding and Lower Bound for Sorting

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

COMP3121/3821/9101/ s1 Assignment 1

ACM-ICPC Indonesia National Contest Problem A. The Best Team. Time Limit: 2s

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

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

An Improved Upper Bound for the Sum-free Subset Constant

2. There are 7 people to be seated at a round table. How many seating arrangements are possible? How many times must they change places so that

4.4 Problems and Solutions (last update 12 February 2018)

BEng (Hons) Telecommunications. Examinations for / Semester 2

This Lecture. We will first introduce some basic set theory before we do counting. Basic Definitions. Operations on Sets.

Discrete Mathematics Introduction

Slides for Faculty Oxford University Press All rights reserved.

Master Theorem, Introduction to Graphs

5 Graphs

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

Solution: It may be helpful to list out exactly what is in each of these events:

Unit 7 Number System and Bases. 7.1 Number System. 7.2 Binary Numbers. 7.3 Adding and Subtracting Binary Numbers. 7.4 Multiplying Binary Numbers

Clustering: Centroid-Based Partitioning

Binomial Coefficient Identities and Encoding/Decoding

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

1. Suppose you are given a magic black box that somehow answers the following decision problem in polynomial time:

Coordinate Graphing Quadrants and Reading Ordered Pairs. TeacherTwins 2015

Sets. X. Zhang Dept. of Computer & Information Sciences Fordham University

Chapter 8 Algorithms 1

CSC Discrete Math I, Spring Sets

THE UNIVERSITY OF MANITOBA

Functions. Jason Filippou UMCP. Jason Filippou UMCP) Functions / 19

HMMT February 2018 February 10, 2018

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.

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

CRPF PUBLIC SCHOOL, ROHINI. EIGHTH INTRA School Mathematics Olympiad 2017 CLASS - XI

Rational Numbers CHAPTER Introduction

CS 1200 Discrete Math Math Preliminaries. A.R. Hurson 323 CS Building, Missouri S&T

Binomial Coefficients

Solutions to Problem Set 1

Math Circles: Pigeons and Rams(ey)

Transcription:

Counting Rosen, Chapter 6 Walls and Mirrors, Chapter 3

Spock's dilemma (Walls and mirrors) n planets in the solar system can only visit k <= n of them how many options does Spock have? call it C(n,k)

C(n,k) choose k out of n Let's formulate a solution recursively consider planet n either visit n Spock must choose k-1 out of n-1 or don't Spock must choose k out of n-1 Can he always choose not to visit n? No! if n==k he must visit all 1 way to choose What if there are 0 planets (left) to visit? 1 way: visit none of them

Recurrence relation We can write this in a recurrence relation a recursive mathematical expression C(n,k) = C(n-1,k-1) + C(n-1,k) pick n or don't C(k,k) = 1 C(n,0) = 1 and we can code this easily as a recursive method.

Combinations Spock just counted the number of choices How can we enumerate them all? How many combinations (subsets) of k out of 0 (n-1) can we create? Notice that this is a generalization of the subset problem from Assign 1

Combinations(5,3) 012 123 234 013 124 014 134 023 what is the largest digit 024 we can place in the first 034 position? Can you generalize that for C(n,k)?

How do we do it? place digits d from lo to hi in position p then recursively place digits d+1 to hi in position p+1 hi: n-k for pos 0, n-k+1 for pos 1, n-k+p for pos p let's play with the code

Counting: the product rule If there are n 1 ways of doing one task, and for each of way of doing the first task there are n 2 ways of doing a second task, then there are n 1 n 2 ways of performing both tasks.

Example You have 6 pairs of pants and 10 shirts. How many different outfits does this give?

Relation to cartesian products The cartesian product of sets A and B is denoted by A x B and is defined as: { (a,b) a A and b B} Fact: A x B = A * B

Product rule Colorado assigns license plates numbers as a-b-c x-y-z, where a,b,c are digits and x,y,z are letters. How many license plates numbers are possible?

More examples How many binary numbers with 7 digits are there? Use the product rule to show that the number of different subsets of a finite set S is 2 S

Product rule and cartesian products A 1 x A 2 x,,x A n = A 1 x A 2 x,,x A n

sum rule Person X has decided to shop at one store today, either in the north end of town or the south end of town. If X visits the north end, X will shop at one of three stores. If X visits the south end of town then X will shop at one of two stores. How many ways could X end up shopping?

The sum rule If a task can be done either in one of n 1 ways or in one of n 2 ways, and none of the n 1 ways is the same as the n 2 ways, then there are n 1 + n 2 ways to do the task. This is a statement about set theory: if two sets A and B are disjoint then A B = A + B

Example A student can choose a computer project from one of three lists. The three lists contain 23, 15, and 4 possible projects. No project is on more than one list. How many possible projects are there to choose from?

The inclusion exclusion principle In set theory terms: A B = A + B - A B Think of it as Venn Diagrams

Try using inclusion / exclusion Suppose you need to pick a password that has length 6-8 characters, where each character is an uppercase letter or a digit, and each password must contain at least one digit. How many possible passwords are there?

The inclusion exclusion principle How many bit strings of length eight start with a 1 or end with 00? 1 - - - - - - - how many? - - - - - - 0 0 how many? if I add these how many have I now counted twice?

The 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.

Examples In a group of 367 people, there must be at least two with the same birthday A drawer contains a dozen brown socks and a dozen black socks, all unmatched. A guy takes socks out at random in the dark. How many socks must he take out to be sure that he has at least two socks of the same color? How many socks must he take out to be sure that he has at least two black socks?

Examples Show that if five different digits between 1 and 8 are selected, there must be at least one pair of these with a sum equal to 9. ask yourself: what are the pigeon holes? what are the pigeons?