bits pilani pilani campus discrete structures for computer science section – 3 - tutorial – 2...

21
BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

Upload: sheena-oliver

Post on 18-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS PilaniPilani Campus

Discrete Structures for Computer ScienceSection – 3 - Tutorial – 2 (21 Aug 2013)

Jagat Sesh Challa

Page 2: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Determine the number of four digit decimal numbers that contain no repeated digits.

This is a problem of arranging 4 of 10 digits 0,1,2,…,9.

So the answer is .

Is this answer correct ???

How many of them have leading zeros?

So, the result is

The result can also be computed as

Problem - 1

Page 3: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

How many 4 digit decimal sequences are possible when digits are allowed to be repeated? How many of them contain one or more repeated digits?

Total number of 4 digit decimal sequences that are possible =

Total number of sequences without repetition =

Therefore, Total number of sequences containing one or more repeated digits = .

Problem - 2

Page 4: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Out of all r digit binary sequences, how many of them have even number of 1’s?

Total number of r digit binary sequences =

Total number of (r-1) digit binary sequences =

These sequences, will either have even number of 1’s or odd number of 1’s.

For the sequences with even number of 1’s we append 0 to make it r digit sequence with even number of 1’s

For the sequences with odd number of 1’s we append 1 to make it r digit sequence with even number of 1’s

Therefore, Total number of r digit sequences with even number of 1’s =

Problem - 3

Page 5: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Among 11 senators, how may ways can we select a committee of five members so that at least one of Senator A and Senator B will be included.

Among 11 senators, Total no of ways to select a committee of 5 members =

No of committees where Senator A is always included =

No of committees where Senator A is always excluded =

No of committees where both Senator A and B are present =

Problem – 4

Page 6: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

No of selections including Senator A but excluding Senator B = .

No of selections including Senator B but excluding Senator A = .

So, total no of ways of selecting committees where either Senator A or B are present

Alternatively, Since the no of ways of selecting a committee excluding both A and B is

So, the total ways of selection =

Problem – 4

Page 7: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

This problem can be solved by applying the principle of inclusion and exclusion.

Let & be the set of ways of selection that includes Senator A and B respectively.

Therefore

Problem – 4

Page 8: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

How many ways can I select 15 cans of soda from a cooler containing large quantities of Coke, Pepsi, Diet Coke, Root Beer and Sprite?

We have to model this problem using the chart:

Here, we set an order of the categories and just count how many from each category are chosen.

Problem - 5

Coke Pepsi Diet Coke

Root Beer

Sprite

A 111 111 111 111 111 15B 11 111111 111111 1 15C 1111 1111111 1111 15

Page 9: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Now, each event will contain fifteen 1’s, but we need to indicate where we transition from one category to the next. If we use 0 to mark our transitions, then the events become:

A: 1110111011101110111

B: 1100111111011111101

C: 0111101111111011110

Thus, associated with each event is a binary string with #1’s = #things to be chosen and #0’s = #transitions between categories.

Problem - 5

Page 10: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

From this example we see that the number of ways to select 15 sodas from a collection of 5 types of soda is C(15 + 4,15) = C(19,15) = C(19,4).

Note that #zeros = #transitions = #categories - 1.

Theorem: The number of ways to fill r slots from n categories with repetition allowed is:

C(r + n - 1, r) = C(r + n - 1, n - 1).

In words, the counts are: C(#slots + #transitions, #slots)

or C(#slots + #transitions, #transitions).

Problem - 5

Page 11: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

How many ways can I fill a box holding 100 pieces of candy from 30 different types of candy?

Solution: Here #slots = 100, #transitions = 30 - 1, so there are C(100+29,100) = 129!/(100!29!) different ways to fill the box.

How many ways if I must have at least 1 piece of each type?

Solution: Now, we are reducing the #slots to choose over to (100 - 30) slots, so there are C(70+29,70) = 99!/70!29!

Problem - 5.1& 5.2

Page 12: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

What is the probability that out of 23 people, none of them have birthday on the same date?

Sample space =

Assume that all these distributions are equiprobable.

No of distributions such that no birthdays of 2 people are on the same day =

In other words it is

Therefore Probability that none of them have same birth date =

Problem - 6

Page 13: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Digital data received from a remote site might fill up 0 to 32 buffers. Let the sample space be , where the sample denotes that of the buffers are full.

It is given that )

Compute

1. Probability that at most 16 buffers are full.

2. Probability that odd number of buffers are full.

3. Probability that odd number of buffers are full and at most 16 of the buffers are full.

Problem - 7

Page 14: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Let A be the event that at most 16 buffers are full. Then . Let B be the event that odd number of buffers are full. Then What we want is

Problem - 7

Page 15: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

8 students are standing in a line for an interview. We want to determine the probability that exactly two 1st yearites, two 2nd yearites, two 3rd yearites and two 4th yearites are standing in the queue.

Sample space = .

No of samples meeting the above criteria =

Therefore probability =

Problem - 8

Page 16: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Generate next and previous 10 permutations of 124653.

Next 10 permutations -

124653 -> 125346 -> 125364 -> 125436 -> 125463 -> 125634 -> 125643 -> 126345 -> 126354 -> 126435

Previous 10 permutations –

124653 -> 124635 -> 124563 -> 124536 -> 124365 -> 124356 -> 123654 -> 123645 -> 123564 -> 123546

Problem - 9

Page 17: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Three dice were rolled. Given that no two faces were the same, what is the probability that there was an ace?

Let A denote the event that there was an ace.

Let B denote the event that no two faces were the same.

What we want is . We have

So

Problem - 10

Page 18: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

A die is rolled. The die has red color on the sides 4 and 6. Let A be the event that 4 has occurred. Let B be the event that a red has come. Find information of both the events. Also, find mutual information of event A given B has occurred.

Problem – 11

Page 19: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Problem -11

Page 20: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Tri-mino Problem

Best explained on the Board…!!!

Problem - 12

Page 21: BITS Pilani Pilani Campus Discrete Structures for Computer Science Section – 3 - Tutorial – 2 (21 Aug 2013) Jagat Sesh Challa

BITS Pilani, Pilani Campus

Q & A