CSCE 235

Homework Assignment 7 (Programming) – Solution

Assigned:  March 4, 2009

Due: 12:30 p.m. March 13, 2009

 (Homework 5 minutes late will not be accepted)

 

Principle of Inclusion-Exclusion

 

1.      (15 points)  How many elements are in  if there are 20 elements in , 13 elements in , and

(a)  (2 points)

(b)  (3 points)

(c)    (5 points)

(d)   (5 points)

 

Solution

 

(a)  (2 points).  Using the principle of Inclusion-Exclusion,

.

(b)  (3 points) .  Using the principle of Inclusion-Exclusion,

.

(c)  (5 points) .  We know that.  .  We also know that .  Thus, we have .   And we have:

And, recall that .  That means,  or .

 

(d) (5 points) .  We know that .  Plugging in the values yields  and that .  Using the principle of Inclusion-Exclusion,

.

 

      *        

 

2.   (10 points)  Of the 125 teams auditioning for the Wombat Best Dance Crew contest:

·         61 teams have training in classical dance

·         70 teams have training in modern dance

·         52 teams have training in ballroom dance

A number of teams will be picked to compete in the Finals.  To qualify for the Finals, a team must have at least training in one of the above dance styles.   If there are:

·         34 teams that have training in both classical dance and modern dance,

·         34 teams that have training in both classical dance and ballroom dance,

·         39 teams that have training in both modern dance and ballroom dance,

·         24 teams that have training in all three dances.

How many teams do NOT qualify for the Finals?

 

Solution

 

      Let

      A = { teams that have training in classical dance },

      B = { teams that have training in modern dance },

      C = { teams that have training in ballroom dance },

and we have , , and .  We also have , , , and .  And we also know that the total number of teams is 125.  Now we are ready to answer the question.  We want to find out the number of teams that do NOT qualify.  That means, we want to find out the number of teams that do not have training in any of the three dance styles.  That is, we want to find:

 

.

 

Using the Principle of Inclusion-Exclusion:

 

= 61 + 70 + 52 – 34 – 34 – 39 + 24 = 100.

 

Thus, the number of teams that do not qualify is simply 125 – 100 = 25.

*  

 

3.         (10 points)  A flower shop (that sells only roses, tulips, and lilies) releases a report of its 100 customers who bought flowers in March 2009.  Every customer bought at least one type of flowers. 

·                     43 customers bought roses

·                     50 customers bought tulips

·                     13 customers bought roses and tulips

·                     10 customers bought roses and lilies

·                     15 customers bought lilies and tulips

·                     6 customers bought roses, tulips and lilies

Solution

 

First, let us setup the problem.  Suppose that we denote R for the set of customers who bought roses, T for the set of customers who bought tulips, and L for the set of customers who bought lilies.  Now we know that  = 100,  = 43,  = 50,  = 13,  = 10,  = 15, and = 6.  We are now ready to answer the questions.

     

      Determine the numbers of customers who bought

 

(a)                 (5 points) lilies

     

That means we are looking for .  To do this, we use the Principle of Inclusion-Exclusion:

100 = 43+50+-13-10-15+6

Rearranging the equation, we have =30.  So, 39 customers bought lilies.

                 

(b)               (5 points) roses and tulips, but not lilies

 

We know that there are 6 customers who bought all flowers.  So, the number of customers who bought only roses and tulips has to be – = 13 – 6 = 7.

(c)        (5 points) roses or tulips, but not both

 

Once again, we can use the Principle of Inclusion-Exclusion:

 

 

(d)       (5 points) more than one type of flowers

 

Let us look the different scenarios.  Basically, we want to count the number of customers who bought exactly three types of flowers, the number of customers who bought exactly two types of flowers, and sum the two numbers. 

 

= 6 is the number of customers who bought exactly three types of flowers.

The number of customers who bought exactly two types of flowers can be broken down into three disjoint sets: those who bought only roses and tulips, those who bought only tulips and lilies, and those who bought only roses and lilies.  The number of customer who bought only roses and tulips is from (b) above: 7.  Similarly, we have   -  = 15 – 6 = 9, and -  = 10 – 6 = 4.  Summing the numbers yields 6 + 7 + 9 + 4 = 26.

 

*  

 

The Addition and Multiplication Rules

 

4.   (10 points)  You are the manager of a talk show and you are in charge of selecting Oscar-nominated actors/actresses to appear on the show. 

 

      You are given the following list of actors:  Richard Jenkins, Frank Langella, Sean Penn, Brad Pitt, and Mickey Rourke. 

 

      You are given the following list of actresses:  Anne Hathaway, Angelina Jolie, Melissa Leo, Meryl Streep, Kate Winslet

 

(a)    (3 points) In how many ways can an actor and an actress be selected to appear on the show?

(b)   (2 points) In how many ways can an actor or an actress selected to appear on the show? 

 

Solution

 

(a)    (3 points) There are 5 actors and 5 actresses.  There are 5 ways to select an actor, and 5 ways to select an actress.  Since it is a sequence because of the pairing, we have (5)(5) = 25 ways to select a pair (one actor and one actress). 

(b)   (2 points) There are 10 people on the lists.  So, 10 ways.

 

*  

 

5.   (10 points) Using only the alphabet letters A, B, C, D, and E, 

(a)    How many two-letter combinations can be formed? 

(b)   How many three-letter combinations can be formed? 

(c)    How many four-letter combinations can be formed? 

(d)   How many two- or three- or four-letter combinations can be formed?

(e)    How many four-letter combinations can be formed if the second letter must be either D or E?

 

(a)    There are 5 options for each letter.  There are (5)(5) = 25 ways of forming two-letter combinations.

(b)   There are (5)(5)(5) = 125 ways of forming three-letter combinations.

(c)    There are (5)(5)(5)(5) = 625 ways of forming four-letter combinations.

(d)   This is simply a collection of the above:  25 + 125 + 625 = 775.

(e)    So, there are 5 options for the first letter, only 3 options for the second letter, and 5 options each for the last two letters.  There are (5)(3)(5)(5) = 375 ways of forming four-letter combinations with the second letter being either D or E.

 

*  

 

6.   (20 points)  A standard deck of 52 playing cards has four suits (spades, hearts, clubs, and diamonds).  Each suit has 13 cards, from 2 to 10 and J, Q, K, and Ace.  In how many ways can one draw from a standard deck of 52 playing cards:

      (a)  (3 points) A club or a diamond or a heart? 

(b)   (3 points) A king (K) or a queen (Q) or a jack (J)? 

(c)    (3 points) A card numbered 6 through 10? 

(d)   (3 points) A card numbered 6 through 10 or a king?

(e)    (5 points) Two cards of different suits?

(f)    (8 points) Two cards: the first card an ace or a king; and then without replacing the first card back into the deck, the second card an ace or a king again? 

 

Solution

 

(a)    (3 points) A club or a diamond or a heart?  There are 13 clubs, 13 diamonds, and 13 hearts.  So, there are a total of 13+13+13 = 39 ways of drawing a club or a diamond or a heart.

(b)   (3 points) A king (K) or a queen (Q) or a jack (J)?  There are 4 kings, 4 queens, and 4 jacks.  So, there are a total of 4+4+4 = 12 ways of drawing a king or a queen or a jack.

(c)    (3 points) For each suit, there are 5 cards numbered 6 through 10.  There are four suits.  So, there are a total of (4)(5) = 20 ways of drawing a card numbered 5 through 10.

(d)   (3 points) Here, there are 4 kings.  Given the solution to (c), we simply add 4 to 20: 24.

(e)    (5 points) There are 52 ways to draw the first card.  Since this first card must belong to one of the four suits, that means there are now only 52-13 = 39 ways to draw the second card.  Since this is a sequence, we have (52)(39) = 2028 ways to draw two cards of different suits.

(f)    (8 points) There are 8 ways of drawing an ace or a king since there are 4 aces and 4 kings.  Since we do not replace the first card back into the deck, there are now 7 ways of drawing an ace or a king, the second time around.  Thus, since this is a sequence, we have (8)(7) = 56.

 

*  

 

The Pigeon-Hole Principle

 

7.   (15 points)  Forty buses are to be used to transport 2500 fans from Lawrence, Kansas to Lincoln, Nebraska for a college football game. Each bus has 80 seats.  Assume one seat per passenger.

(a)    Prove that one of the buses will carry at least 63 passengers.

(b)   Prove that one of the buses will have at least 18 empty seats.

 

Solution

 

(a)    Using the Pigeon-Hole Principle, there are n = 2500 objects (fans) and m = 40 boxes (buses), and one of the boxes must have objects, which is 63.  Thus, one of the buses will carry at least 88 passengers.

 

(b)   There are 2500 passengers.  But there are 40 buses, each with 80 seats.  So, there are (40)(80) = 3200 seats in total.  So, there will be 3200 – 2500 = 700 empty seats.  So, now there are n = 700 objects (empty seats) and m = 40 boxes (buses), and one of the boxes must have  objects, which is 18.  Thus, one of the buses will have at least 18 empty seats.

 

*  

 

8.   (10 points)  You are a magician in front of an audience who are exclusively residents of Nebraska.  You tell the audience that there are at least four people in the audience who live in the same county in Nebraska!  What is the minimum number of people must there be in the audience for your “magic” to work?  (Note: You will need to find out the number of counties in Nebraska.)

 

Solution

 

First, the number of counties in Nebraska is 93.  If we see these counties as boxes, i.e., m = 93, then we need to stuff into the boxes in some way such that at least one of them will have four people!  That is when we can be certain that at least four people were born in the same state.  That is:  = = 4.  Since this is a ceiling function, all we need is that .  Or, .  The minimum value of n that satisfy that is  So, in an audience, there have to be at least 280 people for a magician to be certain that at least four people were born in the same state.  In other words, the “magic” will not work if there are fewer than 279 people in the audience.

 

*  

 

Programming

 

Problems based on (Rosen 2003, Goodaire and Parmenter 2002).