Combinatorics and Probability Coursera Quiz Answers

All Weeks Combinatorics and Probability Coursera Quiz Answers

Combinatorics and Probability Coursera Quiz Answers

Rule of Sum in Programming Answers

Q1) Consider the following python code

1 for _ in range(3):

2 print(“Hi!”)

3 for _ in range(5):

4  print(“Hi!”)

If we run this code, how many times the word ‘Hi!’ will be printed? Try to answer without actually running the code.

Answer = 3

Q2) Consider the following python code

1 for _ in range(8):

2         print(“Hi!”)

3 for _ in range(4):

4 print(“Hi!”)

5 for _ in range(7):

 6        print(“Hi!”)

If we run this code, how many times the word ‘Hi!’ will be printed? Try to answer without actually running the code.

Answer = 7

Operations with Sets Answers

Q1) Consider the sets A = \{1, 2, 4, 6, 7\}A={1,2,4,6,7} and B = \{1, 2, 3, 5, 7\}B={1,2,3,5,7}. What is the intersection A \cap BAB of sets AA and BB?

  • AB={1,3,5,7}
  • AB={1,2,7}
  • AB={1,2,3,4,5,6,7}
  • AB={2,7}

Q2) Consider the sets A = \{1, 2, 4, 6, 7\}A={1,2,4,6,7} and B = \{1, 2, 3, 5, 7\}B={1,2,3,5,7}. What is the union A \cup BAB of sets AA and BB?

  • AB={1,3,5,7}
  • A \cup B = \{1, 2, 7\}AB={1,2,7}
  • AB={1,2,3,4,5,6,7}
  • AB={1,2,4,5,7}

Q3) Consider the sets A = \{1, 3, 4, 6, 7, 8\}A={1,3,4,6,7,8} and B B – the set of all even natural numbers. What is the size |A \cap B|∣AB∣ of intersection of sets AA and BB?

|A|=|B|, |A∪B|=10, and |A∩B|=5

Generalized Rule of Sum Answers

Q1) There are 25 students in the class. Each student should take at least one of the two foreign languages, French and German, and students are allowed to take both courses. It is known that 17 students signed up for the French language course and 14 students signed up for German language course. How many students signed up for both courses?

25 – 2 = 23 learn French or German(or both)

13 + 18 = 31

so 31 – 23 = 8 must learn both.

Q2) How many integer numbers from 1 to 1000 are divisible by 2 or by 3?

734 positive integers which are divisible by at least 2, 3 or 5 from 1 to 1000.

Q3) How many integer numbers from 1 to 1000 are not divisible neither by 2, nor by 3?

There are 333 numbers who are divisible by neither 2 or 3.

Rule of Product in Programming

Q1) Consider the following python code

1 for _ in range(5):

2 for _ in range(7):

3 print("Hi!")

If we run this code, how many times the word ‘Hi!’ will be printed? Try to answer without actually running the code.

Q2) Consider the following python code

1 for _ in range(3):

2       for _ in range(4):

3               for _ in range(5):

4                      print("Hi!")

If we run this code, how many times the word ‘Hi!’ will be printed? Try to answer without actually running the code.

Q3) Consider the following python code

1 for _ in range(2):

2        for _ in range(6):

3                print("Hi!")

4 for _ in range(3):

5        for _ in range(5):

6                print("Hi!")

If we run this code, how many times the word ‘Hi!’ will be printed? Try to answer without actually running the code.

Applications of the Rule of Product Answers

Q1) Suppose there are five teams in some sport participating in some tournament. Each team contains 8 players. We would like to choose one of the players of one of the teams to lead an opening ceremony. How many ways do we have to do it?

Answer is 40.

Q2) Suppose you are picking a t-shirt in some online store. The t-shirt comes in 5 possible colours, 7 possible sizes and 2 neck types (crewneck and v-neck). How many possible variants of the t-shirt are there?

The number of possible variants of the t-shirt. Thus, there will be 70 possible variants of the t-shirt.

Unlimited segments.

Tuples Answers

Q1) Linguists are studying texts in some ancient language with 25 letters. They want to compute how often different 3-letter combinations occur in texts in this language. For this they first need to list all 3-letter combinations. How many combinations will they have?

ancient a language = 25 letters

3 ,letters combinations occurs in texts in this language .

Counting with Restrictions Answers

Q1) How many 3-digit numbers are there that have digits 1, 2 and 3 (each of them exactly once)?

There are 4 numbers and 3 places to put in the numbers: In the ones place, any 4 numbers can be put, so there are 4 choices in the ones place. Similarly for the tens and the hundreds place. So, the total choices are, by multiplication principle- 4∗4∗4=64 And well and good, this was the answer

Q2) A board of 15 people has to pick a chairman of the board, a vice-chairman and a secretary among themselves. All three should be different persons. How many ways do they have to do it?

Ans:- 455

Q3) There are five different tables in the class and five students. Each table can be occupied by only one student. Their studying year consists of 200 days. As a small prank on their teacher students would like to sit in a new way every day, so there are no two days during their studying year such that all students are occupying the same tables. They would like to see whether this is possible. How many ways are there for them to sit in the class?

The only way they’ll have different seating plans everyday is if they share a desk some times. If they never share a desk than they will have to repeat some seating plans on 80 days.

Q4) How many integer numbers between 0 and 9999 are there that have exactly one digit 1 and exactly one digit 3?

The number of integers between 0 and 9999 that have exactly one digit 1 and exactly one digit 3 is 4⋅3⋅8⋅8=768.

Week 2 Quiz Answers

Number of Segments and Diagonals Answers

Q1) What is the number of segments in the picture below? (Each segment joins two circles.)

Q3) A polygonal diagonal is a line segment connecting two nonadjacent vertices of a polygon. Compute the number of diagonals of the following polygon with 16 vertices (and 16 edges).

Forming Sport Teams Answers

Q1) In how many ways can one select a team of five students out of ten students?

252

Q2) In how many ways can one partition ten students into two teams of size five?

(9/4)=126 ways.

Sum of the First Six Rows of Pascal’s Triangle Answers

Q1) What is the sum of all the elements from the first six rows of Pascal’s triangle?

Sum of elements of the 6th row of a Pascal triangle =1+5+10+10+5+1=32.

Expanding (3a-2b)^k Answers

Q1) Find the coefficients of the expansion of (3a-2b)^3(3a−2b)3. That is, represent (3a-2b)^3(3a−2b)3 as

α0​a3+α1​a2b1+α2​a1b2+α3​b3.

Try to compute these coefficients using the binomial theorem (instead of multiplying (3a-2b)(3a−2b) by itself two times).

Enter the values α0​,α1​,α2​,α3​. Separate the values by commas, avoid spaces, do not include plus signs.

For example, for the question (3a-2b)^2(3a−2b)2 the answer would be: 9,-12,4

Answer:

27, -27, 9, -1

Q2) Find the coefficients of the expansion of (3a-2b)^7(3a−2b)7. That is, represent (3a-2b)^7(3a−2b)7 as

α0​a7+α1​a6b1+α2​a5b2+α3​a4b3+α4​a3b4+α5​a2b5+α6​ab6+α7​b7.

Enter the values α0​,α1​,α2​,α3​,α4​,α5​,α6​,α7​. Separate the values by commas, avoid spaces, do not include plus signs.

For example, for the question (3a-2b)^2(3a−2b)2 the answer would be: 9,-12,4

Week 3 Quiz Answers

Salads

Q1) We have an unlimited supply of tomatoes, bell peppers and lettuce. We want to make a salad out of 4 units among these three ingredients (we do not have to use all ingredients). The order in which we use the ingredients does not matter. How many different salads we can make?

We do not have the formula to answer this question yet, so try to list all the salads first or create a program that will do that for you. Then you can count the number of salads by hand (note the answer to the problem should be the number).

Combinations with Repetitions

Q1) Twenty people are voting for one of 5 candidates. They have secret ballot, each voter votes for one of 5 candidates. The result of an election is the number of votes for each of the candidate. How many possible results can this vote have (the result of the vote is determined by the number of votes for each candidate)?

Q2) We have 9 identical candies and we want to distribute them between 3 different sections of our bag. It does not matter which candies go to which section. How many ways do we have to do it?

Concentration for Galton Board

Q1) What is the fraction of beans that end near the center (bins 40-60 among 0-100) for the ideal Galton board with 100 layers? (You may try to write a program, or use some scientific computations tool. For such a problem wolfram alpha should be enough.)

  • less that 50%
  • between 50% and 60%
  • between 60% and 70%
  • between 70% and 80%
  • between 80% and 90%
  • between 90% and 95%
  • between 95% and 97%
  • between 97% and 99%
  • between 99% and 99.9%
  • at least 99.9%

Q2) What is the fraction of beans that end near the center (bins 400-600 among 0-1000) for the ideal Galton board with 1000 layers? (You may try to write a program, or use some scientific computations tool. For such a problem wolfram alpha should be enough.)

  • less that 90%
  • between 90% and 95%
  • between 95% and 99%
  • between 99% and 99.9%
  • between 99.9% and 99.99%
  • between 99.99% and 99.999%
  • more that 99.999%

Week 4 Quiz Answers

Computing Probabilities for Two Dice

Q1) Consider again the setting with red and blue dice where all 36 pairs are equiprobable. Consider the event “red and blue numbers are different”. How many favorable outcomes do we have for this event (out of 36)

30/36

P(R=B) = 1/6 therefore the probability that red doesn’t equal blue is 5/6

out of 36 requires multiplying both by 6.

Q2) In the same setting with 36 (red, blue) outcomes we consider the sum of two numbers (on two dice). What is the most probable value of this sum?

(5/36)

Q3) What is more probable while rolling two dice: to get at least one six, or to have no sixes?

  • Having no sixes is more probable
  • Having at least one six is more probable
  • These two events have the same probability (1/2)

Fair Decisions and Imperfect Coins Answers

Q1) Assume that some dice has six outcomes with probabilities p_1=1/10p1​=1/10, p_2=2/5p2​=2/5, p_3=1/5p3​=1/5, p_4=1/10p4​=1/10, p_5=1/10p5​=1/10, p_6=1/10p6​=1/10. You and a friend came to the restaurant and want to roll this dice once to decide who pays, so that both have equal chances. Can this be done? [Here “dice” stands for one cube, may be may be better to use “die” instead, sorry]

  • Yes
  • No

Q2) Assume that a dice [=die] has six outcomes with probabilities p_1=1/10p1​=1/10, p_2=2/5p2​=2/5, p_3=1/5p3​=1/5, p_4=1/10p4​=1/10, p_5=1/10p5​=1/10, p_6=1/10p6​=1/10. You and two friends came to the restaurant and want to roll this dice once to decide who pays, so that all three eaters have equal chances. Can this be done?

  • Yes
  • No

Q3) Now you want to design a (six-face) dice [=die] (any non-negative p_1,\ldots,p_6p1​,…,p6​ with sum 1 are allowed) that can be used for two, three or four people (rolling the dice once, we can provide equal chances for all eaters). Is it possible?

  • Yes
  • No

Q4) Now you want to design a (6-face) dice [=die] (any non-negative p_1,\ldots,p_6p1​,…,p6​ with sum 1 are allowed) that can be used for two, three, four or five people (rolling the dice once, we can provide equal chances for all eaters). Is it possible?

  • No, such a dice does not exist
  • Yes, it is still possible

Puzzle: Prisoner and King Answers

Q1) A King decides to give a prisoner a chance of being set free. The king places two boxes, 15 white, and 15 black balls on the table. The prisoner can distribute the balls between two boxes in any way with the only constraint that no box is empty. After this, the king picks one of the boxes with probability 1/2 each, and picks a random ball from that box (each ball is picked with equal probability). If the ball happens to be white, then the prisoner is freed. Distribute the balls between the two boxes to maximize prisoner’s chances.

Inclusion-Exclusion Formula Answers

Q1) It is known that two events A and B in some probability space have probabilities 0.7 and 0.8. What is the minimal possible probability of an event “A and B” (the intersection of both events)?

P(AB)=0.5+P(A′B′)P(AB)=0.5+P(A′B′)

Since P(A′B′)≥0P(A′B′)≥0, the minimal value of P(AB)P(AB) is 0.50.5.

Q2) It is known that two events A and B in some probability space have probabilities 0.7 and 0.8. What is the maximal possible probability of an event “A and B” (the intersection of both events)?

1≥1.1−P(A∩B),1≥1.1−P(A∩B),yielding P(A∩B)≥.1P(A∩B)≥.1. If A⊆BA⊆B, then P(A∩B)=P(A)=.4.P(A∩B)=P(A)=.4. This represents the largest possible value for P(A∩B)P(A∩B). so .1≤P(A∩B)≤.4

Prisoner, King and Conditional Probabilities

Q1) There are two boxes; the first one contains 10 white balls and 5 black balls; the other one contains 10 black balls and 5 white balls. King randomly selects a box (with equal probabilities) and then randomly takes a ball from this box (with equal probabilities). What is the probability that King selected the first box under the condition that the ball he selected is white?

P(F|W)=P(F∩W)P(W)=P(F)×P(W|F)P(F)×P(W|F)+P(S)×P(W|S)=12×2312×23+12×13=23

More Conditional Probabilities

Q1) Mary tosses the coin three times. What is conditional probability of the event “all tails” under the condition “at least two tails”?

(3/7)

Q2) [IMPORTANT: there was a wrong answer for this problem, now corrected. Apologies…] The conditional probability Pr[B|A] is 4/5; the conditional probability P[B|not A] is 2/5, and the unconditional probability of B is 1/2. What is the probability of A?

P(B)=P(A)P(B|A)+P(A¯¯¯¯)P(B|A¯¯¯¯)P(B)=P(A)P(B|A)+P(A¯)P(B|A¯)

P(A¯¯¯¯)=1−P(A)P(A¯)=1−P(A)

More About Independence

Q1) Two events A and B are independent, Pr[A}=p, Pr[B]=q. What is the probability of the event “A and B”?

P(B) = 5/6 = 0.833333

Q2) Two events A and B are independent, Pr[A}=p, Pr[B]=q. What is the probability of the event “A or B”?

P(AUB) = 0.3+0.6-.18
or, P(AUB)=0.72

Q3) Two events A and B are independent, Pr[A}=p, Pr[B]=q. What is the probability of the event “neither A nor B”?

 =1- P(AnB) =1- 0.60 =0.40

Week 5 Quiz Answers

Random Variables

Q1) Suppose we throw a dice with numbers from 1 to 6 on its sides two times in a row. In the following list pick those elements that are random variables (and not events).

  • The sum of numbers on both dices
  • The number in the first throw is greater than the number in the second throw
  • The difference between numbers on the first and the second throw
  • The difference between numbers in the first and the second throw is positive
  • The product of numbers on both dices is even
  • The number on the first dice

Q2) Suppose we toss a coin two times in a row. Consider the random variable that is equal to the number of heads in these throws. What is the probability of the event that this random variable has value 1?

Average Answers

Q1) Suppose number a is at least 1 and at most 5, and number b is at least 2 and at most 7. What is the smallest possible value for the average of a and b?

Q2) Suppose number a is at least 1 and at most 5, and number b is at least 2 and at most 7. What is the largest possible value for the average of a and b?

Q3) Student got scores 78, 85, 87 and 93 on four tests. What is his average score?

The average from 82.33 to 85.

Q4) Suppose we throw a coin many times. Consider a random variable that is equal to 1 if the outcome of a throw is ‘tails’ and that is 0 if the outcome is ‘heads’. What is the approximate value of an average outcome?

Expectations Answers

Q1) Consider a random variable with outcomes 0 and 1 having probabilities 1/3 and 2/3 respectively. What is the expected value of this random variable?

x= 1 3 4

p((x)= 1/4 1/2 1/3

E(x)= sum (x*P(x))

Q2) Consider a random variable with outcomes 1, 3 and 4 having probabilities 1/4, 1/2 and 1/4 respectively. What is the expected value of this random variable?

Linearity of Expectation Answers

Q1) Suppose we throw a coin 4 times in a row. What is the expected number of tails in these throws?

p(x=3)=(4c3).(1/2)^3.(1/2)^1 = 1/4

Q2) Suppose we throw a dice 4 times in a row. What is the expected number of outcomes 1 in these throws?

(4/24)

Bob’s Party

Q1) Bob has a birthday and is throwing a party for his friends. He invited 30 people to the party. From the previous experience Bob knows that each of his friends will show up to the party with probability 2/5 independently of others. What is the expected number of guests on Bob’s party?

More Linearity

Q1) Suppose we toss a coin 20 times in a row. We are considering how many times it happens that we have an outcome `heads’ and the next outcome is `tails’. This is a random variable since it depends on outcome of our tosses. What is the expectation of this random variable?

Let X be the number of heads in 20 tosses.

We want P(X>=10) = 1 – P(X<=9) = 1 – 0.4119 = 0.5881

Average Income

Q1) An internet article claims that 10% of citizens of a certain country earn at least 15 times more money than the average income in this country. Can it be the case?

  • Yes, this is possible
  • No, this is impossible

Bob’s Party Revisited

Q1) Bob has a birthday and is throwing a party for his friends. He invited 30 people to the party. From the previous experience Bob knows that each of his friends will show up to the party with probability 2/5 independently of others. Recall that we already have computed before the expected number of guests at the party and it is equal to 12. Bob is deciding how much snacks will be at the party and he would like to upper bound the probability that there will be at least 18 people. What upper bound on this probability can he get from Markov’s inequality?

Alice’s tests

Q1) Alice makes 3 mistakes on average on a random test in the course she is taking. What is the best upper bound we can get from Markov’s inequality on the probability that she will make at least 15 mistakes? The answer to the problem should be a number between 0 and 1 (not a percent).

Week 6 Quiz Answers

Quiz 1: Final Project: Dice Game

Q1. Project Overview
In this series of three programming tasks, we will implement together a program that will play optimally in a tricky dice game! You program will be given a list of dices and will decide who chooses the dice first (you or your opponent).

When the dices are chosen, we will simulate 10000 throws. Each time your number is greater, you get $1 from your opponent. Conversely, each time your number is smaller, you pay $1 to your opponent.

Your ultimate goal is to implement a program that always wins in such a simulation.

First Task: Compare Two Dices
Implement a function that takes two dices as input and computes two values: the first value is the number of times the first dice wins (out of all possible 36 choices), the second value is the number of times the second dice wins. We say that a dice wins if the number on it is greater than the number on the other dice.

To debug your implementation, use the following test cases:

Sample 1

Input: dice1 = [1, 2, 3, 4, 5, 6], dice2 = [1, 2, 3, 4, 5, 6]

Output: (15, 15)

Sample 2

Input: dice1 = [1, 1, 6, 6, 8, 8], dice2 = [2, 2, 4, 4, 9, 9]

Output: (16, 20)

def count_wins(dice1, dice2):
assert len(dice1) == 6 and len(dice2) == 6
dice1_wins, dice2_wins = 0, 0

# write your code here

return (dice1_wins, dice2_wins)

Reset

Q2. Second Task: Is there the Best Dice?
Now, your goal is to check whether among the three given dices there is one that is better than the remaining two dices.

Implement a function that takes a list of dices and checks whether there is dice (in this list) that is better than all other dices. We say that a dice is better than another one, if it wins more frequently (that is, out of all 36 possibilities, it wins in aa cases, while the second one wins in bb cases, and a>ba>b). If there is such a dice, return its (0-based) index. Otherwise, return -1.

Use the following datasets for debugging:

Sample 1

Input: [[1, 1, 6, 6, 8, 8], [2, 2, 4, 4, 9, 9], [3, 3, 5, 5, 7, 7]]

Output: -1

Sample 2

Input: [[1, 1, 2, 4, 5, 7], [1, 2, 2, 3, 4, 7], [1, 2, 3, 4, 5, 6]]

Output: 2

Sample 3

Input: [[3, 3, 3, 3, 3, 3], [6, 6, 2, 2, 2,
2], [4, 4, 4, 4, 0, 0], [5, 5, 5, 1, 1, 1]]

Output: -1

def find_the_best_dice(dices):
assert all(len(dice) == 6 for dice in dices)

# write your code here
# use your implementation of count_wins method if necessary

return -1

Reset

Q3. Third Task: Implement a Strategy
You are now ready to play!

Implement a function that takes a list of dices (possibly more than three) and returns a strategy. The strategy is a dictionary:

If, after analyzing the given list of dices, you decide to choose a dice first, set strategy[“choose_first”] to True and set strategy[“first_dice”] to be the (0-based) index of the dice you would like to choose

If you would like to be the second one to choose a dice, set strategy[“choose_first”] to False. Then, specify, for each dice that your opponent may take, the dice that you would take in return. Namely, for each i from 0 to len(dices)-1, set strategy[i] to an index j of the dice that you would take if the opponent takes the i-th dice first.

Use the following datasets for debugging:

Sample 1

Input: [[1, 1, 4, 6, 7, 8], [2, 2, 2, 6, 7, 7], [3, 3, 3, 5, 5, 8]]

Output: {‘choose_first’: False, 0: 1, 1: 2, 2: 0}

Sample 2

Input: [[4, 4, 4, 4, 0, 0], [7, 7, 3, 3, 3, 3], [6, 6, 2, 2, 2, 2], [5, 5, 5, 1, 1, 1]]

Output: {‘choose_first’: True, ‘first_dice’: 1}

Note that your answers do not have to coincide with the answers above. First, the order of elements does not matter in the dictionary. Second, the dictionary might contain extra information that is not required in the statement of the problem. For example, {0: 3, ‘first_dice’: 1, ‘choose_first’: True} is also a correct output in Sample 2.

def compute_strategy(dices):
assert all(len(dice) == 6 for dice in dices)

strategy = dict()
strategy["choose_first"] = True
strategy["first_dice"] = 0
for i in range(len(dices)):
    strategy[i] = (i + 1) % len(dices)

# write your code here

Get All Course Quiz Answers of Software Development Lifecycle Specialization

Software Development Processes and Methodologies Quiz Answers

Agile Software Development Coursera Quiz Answers

Lean Software Development Coursera Quiz Answers

Engineering Practices for Building Quality Software Quiz Answers

Team Networking Funda
Team Networking Funda

We are Team Networking Funda, a group of passionate authors and networking enthusiasts committed to sharing our expertise and experiences in networking and team building. With backgrounds in Data Science, Information Technology, Health, and Business Marketing, we bring diverse perspectives and insights to help you navigate the challenges and opportunities of professional networking and teamwork.

Leave a Reply

Your email address will not be published. Required fields are marked *