5.1 Basic counting principles

Similar documents
Factoring Numbers. Factoring numbers means that we break numbers down into the other whole numbers that multiply


Discrete Mathematics: Homework 7 solution. Due:

Just the Factors, Ma am

Pigeonhole Principle Solutions

Full and Complete Binary Trees

Lempel-Ziv Coding Adaptive Dictionary Compression Algorithm

Math 55: Discrete Mathematics

Ex. 2.1 (Davide Basilio Bartolini)

10.2 Series and Convergence

The Goldberg Rao Algorithm for the Maximum Flow Problem

Basics of Counting. The product rule. Product rule example. 22C:19, Chapter 6 Hantao Zhang. Sample question. Total is 18 * 325 = 5850

Information Theory and Coding Prof. S. N. Merchant Department of Electrical Engineering Indian Institute of Technology, Bombay

Factorizations: Searching for Factor Strings

Sequences. A sequence is a list of numbers, or a pattern, which obeys a rule.

Solution for Homework 2

The correlation coefficient

3.1. Solving linear equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

Fast Sequential Summation Algorithms Using Augmented Data Structures

International Journal of Advanced Research in Computer Science and Software Engineering

Cardinality. The set of all finite strings over the alphabet of lowercase letters is countable. The set of real numbers R is an uncountable set.

6.3 Conditional Probability and Independence

FACTORS, PRIME NUMBERS, H.C.F. AND L.C.M.

LINEAR INEQUALITIES. Mathematics is the art of saying many things in many different ways. MAXWELL

2.1. Inductive Reasoning EXAMPLE A

1.6 The Order of Operations

k, then n = p2α 1 1 pα k

03 - Lexical Analysis

Ch5: Discrete Probability Distributions Section 5-1: Probability Distribution

Topology-based network security

COUNTING SUBSETS OF A SET: COMBINATIONS

Reading 13 : Finite State Automata and Regular Expressions

We can express this in decimal notation (in contrast to the underline notation we have been using) as follows: b + 90c = c + 10b

Chapter 4: Computer Codes

Chapter 11 Number Theory

Analysis of Algorithms, I

Design: a mod-8 Counter

Information, Entropy, and Coding

Calculate Highest Common Factors(HCFs) & Least Common Multiples(LCMs) NA1

A permutation can also be represented by describing its cycles. What do you suppose is meant by this?

Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

=

Equations, Inequalities & Partial Fractions

Symbol Tables. Introduction

Regular Languages and Finite State Machines

ER E P M A S S I CONSTRUCTING A BINARY TREE EFFICIENTLYFROM ITS TRAVERSALS DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF TAMPERE REPORT A

Acquisition Lesson Planning Form Key Standards addressed in this Lesson: MM2A3d,e Time allotted for this Lesson: 4 Hours

A Non-Linear Schema Theorem for Genetic Algorithms

Math 55: Discrete Mathematics

35 Permutations, Combinations and Probability

1(a). How many ways are there to rearrange the letters in the word COMPUTER?

VORD TOOLKIT: HOW TO

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

Arkansas Tech University MATH 4033: Elementary Modern Algebra Dr. Marcel B. Finan

ECE302 Spring 2006 HW4 Solutions February 6,

6.4 Normal Distribution

Math 408, Actuarial Statistics I, Spring Solutions to combinatorial problems

South East of Process Main Building / 1F. North East of Process Main Building / 1F. At 14:05 April 16, Sample not collected

HISTOGRAMS, CUMULATIVE FREQUENCY AND BOX PLOTS

Examples of Functions

4. Continuous Random Variables, the Pareto and Normal Distributions

Math Workshop October 2010 Fractions and Repeating Decimals

15.0. Percent Exceptions

Regular Languages and Finite Automata

2) Write in detail the issues in the design of code generator.

Black Problems - Prime Factorization, Greatest Common Factor and Simplifying Fractions

SHARP BOUNDS FOR THE SUM OF THE SQUARES OF THE DEGREES OF A GRAPH

Counting in base 10, 2 and 16

Question of the Day. Key Concepts. Vocabulary. Mathematical Ideas. QuestionofDay

Fundamentele Informatica II

Private Record Linkage with Bloom Filters

4/1/2017. PS. Sequences and Series FROM 9.2 AND 9.3 IN THE BOOK AS WELL AS FROM OTHER SOURCES. TODAY IS NATIONAL MANATEE APPRECIATION DAY

(Refer Slide Time: 01.26)

Binary Search Trees CMPSC 122

Classification/Decision Trees (II)

Solving Rational Equations

Standard Deviation Estimator

Common Tools for Displaying and Communicating Data for Process Improvement

Working with whole numbers

Lesson 1. Basics of Probability. Principles of Mathematics 12: Explained! 314

EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics and Computer Science

Playing with Numbers

An Introduction to Number Theory Prime Numbers and Their Applications.

Lossless Grey-scale Image Compression using Source Symbols Reduction and Huffman Coding

Cubes and Cube Roots

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Encoding Text with a Small Alphabet

Math 319 Problem Set #3 Solution 21 February 2002

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

The Answer to the 14 Most Frequently Asked Modbus Questions

MACM 101 Discrete Mathematics I

Class Notes CS Creating and Using a Huffman Code. Ref: Weiss, page 433

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

The string of digits in the binary number system represents the quantity

MEP Pupil Text 12. A list of numbers which form a pattern is called a sequence. In this section, straightforward sequences are continued.

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Optimal Binary Search Trees Meet Object Oriented Programming

SQUARE-SQUARE ROOT AND CUBE-CUBE ROOT

Chapter 5 Discrete Probability Distribution. Learning objectives

Transcription:

Counting problems arise throughout mathematics and computer science. Motivating Example: A password for an e-mail account should consist of six to eight characters. Each of these characters must be a digit or a letter of the alphabet (lower case or upper case). Each password must contain at least one digit and at least one character. How many passwords are there? Example: There are 20 students in our class. Each student has a pair of hands. How many hands do we have in our class? 1

5.1 Tree diagrams Counting problems can be solved using tree diagrams. tree root branches tree nodes leaves We represent the possible outcomes by the leaves. Example 8: Bit strings of length three that don't have two consecutive 0s. 1 st bit 1 0 2 nd bit 1 0 1 3 rd bit 1 1 1 0 0 111 110 101 011 010 2

Example 2: how many difference license plates are available if each plate contains a sequence of three letters followed by two digits? Solution: _ letters digits Answer = 1 757 600 3

The product rule: Suppose that a procedure can be broken down into sequence of two tasks. Suppose there are n 1 ways to do the first task. Suppose there are n 2 ways to do the second task (for each of those n 1 ways). Then there are n 1 n 2 ways to do the procedure. Also applies for more than 2 tasks. 4

Example: A student can choose a computer project from one of two groups. The first group contains 12 projects. The second group contains 19 possible projects. All projects are different. How many possible projects are there to choose from? The sum rule: If a task can be done either in one of n 1 ways or in one of n 2 ways (no overlap), then there are n 1 + n 2 ways to do the task. 5

Example: There are 20 students in our class. Each student has a pair of hands. How many hands do we have in our class if we do not count the tallest students' hands nor do we count the left hand of the shortest student? Basic subtraction rule: If a task can be done in n 1 ways, except that there are n 2 forbidden ways, then there are n 1 - n 2 ways to do the task. 6

Example: Let's go back to the question about the password. A password for an e-mail account should consist of six to eight characters. Each of these characters must be a digit or a letter of the alphabet (lower case or upper case). Each password must contain at least one digit and at least one character. How many passwords are there? Solution: Let P be the total number of possible passwords. Let P 6 denote the number of possible passwords of length 6, P 7 denote the number of possible passwords of length 7, and P 8 denote the number of possible passwords of length 8. By the sum rule P = P 6 + P 7 + P 8. Let's find P 6 : (lower case letters, upper case letters, digits: 26+26+10 = 62) 62 62 62 62 62 62 = 62 6 Recall restrictions: at least one digits and at least one character. We need to exclude the forbidden cases... 7

P 6 = 62 6-10 6-52 6 Similarly, P 7 =? and P 8 =? Hence, P = P 6 + P 7 + P 8 =... = 167 410 838 583 040 8

5.1 Inclusion - Exclusion principle Example: How many bit strings of length eight that either start with a 1 bit or end with the two bits 11? Solution: A. Let's count the ones that start with 1: 1 _ 1 2 2 2 2 2 2 2 = 2 7 B. Let's count the ones that end with 11: 1 1 2 2 2 2 2 2 1 1 = 2 6 Is the answer = 2 7 + 2 6? (by the sum rule?) 9

5.1 Inclusion - Exclusion principle Example: How many bit strings of length eight that either start with a 1 bit or end with the two bits 11? Solution: A. Let's count the ones that start with 1: 1 _ 1 2 2 2 2 2 2 2 = 2 7 B. Let's count the ones that end with 11: 1 1 2 2 2 2 2 2 1 1 = 2 6 C. Let's count the ones that start with 1 and end with 11: 1 _ 1 1 1 2 2 2 2 2 1 1 = 2 5 - these combinations are already included in the above two cases (therefore, we need to subtract them from the sum of the first two) Total: 2 7 + 2 6-2 5 = 128 + 64 32 = 160 10

The Inclusion Exclusion Principle (less basic subtraction principle) - Suppose a task can be done in n 1 or in n 2 ways (but some of the n 1 ways to do the task are the same as some of the n 2 ways to do the task). - To count: Add them up: n 1 +n 2 (but this overcounts ) Subtract: n 1 +n 2 - (# of ways to do the task in a way that is both among the set of n 1 ways and n 2 ways) 11

5.1 Inclusion - Exclusion principle The Inclusion Exclusion Principle n 1 +n 2 -(# of ways to do the task in a way that is both among the set of n 1 ways and n 2 ways) We can rephrase this counting principle in terms of sets. Let A 1 and A 2 be sets. There are A 1 ways to select an element from A 1, and A 2 ways to select an element from A 2. A 1 U A 2 = A 1 + A 2 - A 1 A 2 Example: Every student in a discrete mathematics class is either a computer science or a mathematics major or is a joint major in these two subjects. How many students are in the class if there are 38 computer science majors (including joint majors), 23 mathematics majors (including joint majors), and 7 joint majors? Answer = 54 12

5.1 Practice Problems Good Practice Problems (6.1) A: 1, 3, 7 B: 9, 11, C: 13, 15 D: 17, 25 13