1. Trang chủ
  2. » Luận Văn - Báo Cáo

Giao trinh bai tap dsp midterm hkii 2012 2013

73 268 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 73
Dung lượng 7,62 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Huynh Tuong Nguyen, Vinh Tan Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations Sum Rule Example A student can choose a project from one of three

Trang 1

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Chapter 6

Counting

Discrete Structures for Computing on 25 April 2011

Trang 2

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Trang 3

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Introduction

Example

• In games: playing card, gambling, dices,

• How many allowable passwords on a computer system?

• How many ways to choose a starting line-up for a football

Trang 4

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Introduction

Example

• In games: playing card, gambling, dices,

• How many allowable passwords on a computer system?

• How many ways to choose a starting line-up for a football

Trang 5

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Trang 6

Huynh Tuong Nguyen, Vinh Tan

Contents

Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Trang 7

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Problems

• Number of passwords a hacker should try if he wants to use

brute force attack (exhaustive key search)

• Number of possible outcomes in experiments

• Number of operations used by an algorithm

Trang 8

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Problems

• Number of passwords a hacker should try if he wants to use

brute force attack (exhaustive key search)

• Number of possible outcomes in experiments

• Number of operations used by an algorithm

Trang 9

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Problems

• Number of passwords a hacker should try if he wants to use

brute force attack (exhaustive key search)

• Number of possible outcomes in experiments

• Number of operations used by an algorithm

Trang 10

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Product Rule

Example

There are32routers in a computer center Each router has24

ports How many different ports in the center?

Definition (Product Rule (Luật nhân))

Suppose that a procedure can be broken down into a sequence oftwo tasks If there are n1ways to do the first task and for each ofthese ways of doing the first task, there aren2 ways to do thesecond task, then there aren1× n2 ways to do the procedure

Can be extended to T1, T2, , Tmtasks in sequence

Trang 11

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Product Rule

Example

There are32routers in a computer center Each router has24

ports How many different ports in the center?

Solution

There are two tasks to choose a port:

1 picking a router

2 picking a port on this router

Because there are 32 ways to choose the router and 24 ways to

choose the port no matter which router has been selected, the

number of ports are 32 × 24 = 768 ports

Definition (Product Rule (Luật nhân))

Suppose that a procedure can be broken down into a sequence oftwo tasks If there are n1ways to do the first task and for each ofthese ways of doing the first task, there aren2 ways to do thesecond task, then there aren1× n2 ways to do the procedure

Can be extended to T1, T2, , Tmtasks in sequence

Trang 12

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Product Rule

Example

There are32routers in a computer center Each router has24

ports How many different ports in the center?

Solution

There are two tasks to choose a port:

1 picking a router

2 picking a port on this router

Because there are 32 ways to choose the router and 24 ways to

choose the port no matter which router has been selected, the

number of ports are 32 × 24 = 768 ports

Definition (Product Rule (Luật nhân))

Suppose that a procedure can be broken down into a sequence of

two tasks If there are n1ways to do the first task and for each of

these ways of doing the first task, there aren2 ways to do the

Can be extended to T1, T2, , Tmtasks in sequence

Trang 13

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Product Rule

Example

There are32routers in a computer center Each router has24

ports How many different ports in the center?

Solution

There are two tasks to choose a port:

1 picking a router

2 picking a port on this router

Because there are 32 ways to choose the router and 24 ways to

choose the port no matter which router has been selected, the

number of ports are 32 × 24 = 768 ports

Definition (Product Rule (Luật nhân))

Suppose that a procedure can be broken down into a sequence of

Trang 14

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

More examples

Example (1)

Two new students arrive at the dorm and there are 12 rooms

available How many ways are there to assign differentrooms to

Trang 15

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

More examples

Example (1)

Two new students arrive at the dorm and there are 12 rooms

available How many ways are there to assign differentrooms to

Trang 16

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

More examples

Example (1)

Two new students arrive at the dorm and there are 12 rooms

available How many ways are there to assign differentrooms to

two students?

Example (2)

How many different bit strings of length seven are there?

Example (3)

How many one-to-one functions are there from a set with m

elements to one with m elements?

Trang 17

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Sum Rule

Example

A student can choose a project from one of three fields:

Information system (32 projects), Software Engineering (12

projects) and Computer Science (15 projects) How many ways are

there for a student to choose?

Solution: 32 + 12 + 15Definition (Sum Rule (Luật cộng))

If a task can be done eitherin one of n1ways or in one of n2

ways, there none of the set of n1 ways is the same as any of theset of n2 ways, then there aren1+ n2 ways to do the task

Can be extended to n1, n2, , nmdisjoint ways

Trang 18

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Sum Rule

Example

A student can choose a project from one of three fields:

Information system (32 projects), Software Engineering (12

projects) and Computer Science (15 projects) How many ways are

there for a student to choose?

Solution: 32 + 12 + 15

Definition (Sum Rule (Luật cộng))

If a task can be done eitherin one of n1ways or in one of n2

ways, there none of the set of n1 ways is the same as any of theset of n2 ways, then there aren1+ n2 ways to do the task

Can be extended to n1, n2, , nmdisjoint ways

Trang 19

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Sum Rule

Example

A student can choose a project from one of three fields:

Information system (32 projects), Software Engineering (12

projects) and Computer Science (15 projects) How many ways are

there for a student to choose?

Solution: 32 + 12 + 15

Definition (Sum Rule (Luật cộng))

If a task can be done eitherin one of n1ways or in one of n2

ways, there none of the set of n1 ways is the same as any of the

set of n2 ways, then there aren1+ n2 ways to do the task

Can be extended to n1, n2, , nmdisjoint ways

Trang 20

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Sum Rule

Example

A student can choose a project from one of three fields:

Information system (32 projects), Software Engineering (12

projects) and Computer Science (15 projects) How many ways are

there for a student to choose?

Solution: 32 + 12 + 15

Definition (Sum Rule (Luật cộng))

If a task can be done eitherin one of n1ways or in one of n2

ways, there none of the set of n1 ways is the same as any of the

set of n2 ways, then there aren1+ n2 ways to do the task

Can be extended to n1, n2, , nmdisjoint ways

Trang 21

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Using Both Rules

Example

In a computer language, the name of a variable is a string ofone

or two alphanumeric characters, where uppercase and lowercase

letters are not distinguished Moreover, a variable namemust

begin with a letter and must bedifferent fromthe five strings of

two characters that are reserved for programming use How many

different variables names are there in this language?

Solution

Let V equal to the number of different variable names

Let V1 be the number of these that are one character long, V2bethe number of these that are two characters long Then, by sumrule, V = V1+ V2

Note that V1= 26, because it must be a letter Moreover, thereare 26 · 36 strings of length two that begin with a letter and endwith an alphanumeric character However, five of these areexcluded, so V2= 26 · 36 − 5 = 931 Hence V = V1+ V2= 957different names for variables in this language

Trang 22

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Using Both Rules

Example

In a computer language, the name of a variable is a string ofone

or two alphanumeric characters, where uppercase and lowercase

letters are not distinguished Moreover, a variable namemust

begin with a letter and must bedifferent fromthe five strings of

two characters that are reserved for programming use How many

different variables names are there in this language?

Solution

Let V equal to the number of different variable names

Let V1 be the number of these that are one character long, V2be

the number of these that are two characters long Then, by sum

rule, V = V1+ V2

Note that V1= 26, because it must be a letter Moreover, there

are 26 · 36 strings of length two that begin with a letter and end

with an alphanumeric character However, five of these are

Trang 23

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Inclusion-Exclusion

Example

How many bit strings of length eighteither start with a 1bitor

end with the two bits 00?

Solution

• Bit string of length eight that begins with a 1 is 2 = 128ways

• Bit string of length eight that ends with 00 is 26= 64 ways

• Bit string of length eight that begins with 1 andends with00: 25= 32 ways

Number of satisfied bit strings are 27+ 26− 25= 160 ways

Trang 24

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Inclusion-Exclusion

Example

How many bit strings of length eighteither start with a 1bitor

end with the two bits 00?

Solution

• Bit string of length eight that begins with a 1 is 27= 128

ways

• Bit string of length eight that ends with 00 is 2 = 64 ways

• Bit string of length eight that begins with 1 andends with00: 25= 32 ways

Number of satisfied bit strings are 27+ 26− 25= 160 ways

Trang 25

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Inclusion-Exclusion

Example

How many bit strings of length eighteither start with a 1bitor

end with the two bits 00?

Solution

• Bit string of length eight that begins with a 1 is 27= 128

ways

• Bit string of length eight that ends with 00 is 26= 64 ways

• Bit string of length eight that begins with 1 andends with00: 25= 32 ways

Number of satisfied bit strings are 27+ 26− 25= 160 ways

Trang 26

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Inclusion-Exclusion

Example

How many bit strings of length eighteither start with a 1bitor

end with the two bits 00?

Solution

• Bit string of length eight that begins with a 1 is 27= 128

ways

• Bit string of length eight that ends with 00 is 26= 64 ways

• Bit string of length eight that begins with 1 andends with

00: 25= 32 ways

Number of satisfied bit strings are 2 + 2 − 2 = 160 ways

Trang 27

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

Combinations

Inclusion-Exclusion

Example

How many bit strings of length eighteither start with a 1bitor

end with the two bits 00?

Solution

• Bit string of length eight that begins with a 1 is 27= 128

ways

• Bit string of length eight that ends with 00 is 26= 64 ways

• Bit string of length eight that begins with 1 andends with

00: 25= 32 ways

Number of satisfied bit strings are 2 + 2 − 2 = 160 ways

Trang 28

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Inclusion-Exclusion

Example

How many bit strings of length eighteither start with a 1bitor

end with the two bits 00?

Solution

• Bit string of length eight that begins with a 1 is 27= 128

ways

• Bit string of length eight that ends with 00 is 26= 64 ways

• Bit string of length eight that begins with 1 andends with

00: 25= 32 ways

Number of satisfied bit strings are 27+ 26− 25= 160 ways

Trang 29

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

CombinationsInclusion-Exclusion

|A ∪ B| = |A| + |B| − |A ∩ B|

Trang 30

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

CombinationsInclusion-Exclusion

|A ∪ B| = |A| + |B| − |A ∩ B|

Trang 31

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & CombinationsInclusion-Exclusion

|A ∪ B| = |A| + |B| − |A ∩ B|

Trang 32

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

CombinationsInclusion-Exclusion

|A ∪ B ∪ C| =???

Trang 33

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

CombinationsInclusion-Exclusion

|A ∪ B ∪ C| =???

Trang 34

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations &

CombinationsInclusion-Exclusion

|A ∪ B ∪ C| =???

Trang 35

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & CombinationsInclusion-Exclusion

|A ∪ B ∪ C| =???

Trang 36

Huynh Tuong Nguyen, Vinh Tan

Contents Introduction Counting Techniques Pigeonhole Principle Permutations & Combinations

Example

In a certain survey of a group of students,87students indicated

they likedArsenal,91indicated that they likedChelseaand91

indicated that they likedMU Of the students surveyed, 9liked

onlyArsenal,10liked onlyChelsea,12liked onlyMUand40liked

all three clubs How many of the student surveyed likedboth MU

andChelseabut notArsenal?

Ngày đăng: 09/12/2016, 07:18

TỪ KHÓA LIÊN QUAN