SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Anany Levitin
Chapter:
Fundamentals Of The Analysis Of Algorithm Efficiency
Exercise:
2.1 Exercise
Question:4 | ISBN:9780132316811 | Edition: 3

Question

4. a. Glove selection There are 22 gloves in a drawer: 5 pairs of red gloves, 4 pairs of yellow, and 2 pairs of green. You select the gloves in the dark and can check them only after a selection has been made.What is the smallest number of gloves you need to select to have at least one matching pair in the best case? In the worst case?


b. Missing socks Imagine that after washing 5 distinct pairs of socks, you discover that two socks are missing. Of course, you would like to have the largest number of complete pairs remaining. Thus, you are left with 4 complete pairs in the best-case scenario and with 3 complete pairs in the worst case. Assuming that the probability of disappearance for each of the 10 socks is the same, find the probability of the best-case scenario; the probability of the worst-case scenario; the number of pairs you should expect in the average case.

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

a.

Glove selection:

In the best-case scenario, you can select all gloves except one without getting a matching pair, and then the next glove you select will form a matching pair. Here's the breakdown:

  • Select 5 red gloves (10 individual gloves).
  • Select 4 yellow gloves (8 individual gloves).
  • Select 2 green gloves (4 individual gloves).
  • Total gloves selected so far: 10 + 8 + 4 = 22.

In the best case, you need to select all 22 gloves to ensure you have at least one matching pair. In the worst-case scenario, you can keep selecting gloves in such a way that you never form a matching pair until you have selected all but one glove of each color. Here's the breakdown:

  • Select 5 red gloves (10 individual gloves).
  • Select 4 yellow gloves (8 individual gloves).
  • Select 2 green gloves (4 individual gloves).
  • Total gloves selected so far: 10 + 8 + 4 = 22. In the worst case, you also need to select all 22 gloves to ensure you have at least one matching pair.

So, in both the best and worst cases, you need to select all 22 gloves to guarantee at least one matching pair.

b.

Missing socks: In the best-case scenario, you will lose one sock from each pair except one. Here's how it breaks down:

  • 4 complete pairs (8 socks).
  • 1 sock from the fifth pair. Total socks remaining in the best case: 8 + 1 = 9.

In the worst-case scenario, you will lose both socks from one pair and one sock from each of the remaining pairs. Here's how it breaks down:

  • 3 complete pairs (6 socks).
  • 1 sock from the fourth pair.
  • 1 sock from the fifth pair. Total socks remaining in the worst case: 6 + 1 + 1 = 8.

To calculate the probability of these scenarios, you need to consider the combinations of socks you can lose. Since each sock has an equal probability of being lost, you can use combinatorics:

  • Probability of the best-case scenario: C(10, 1) * C(8, 1) = 10 * 8 = 80 combinations.
  • Probability of the worst-case scenario: C(10, 2) * C(8, 1) = 45 * 8 = 360 combinations.

Now, you need to normalize these probabilities by dividing by the total number of possible outcomes, which is C(10, 2) = 45 combinations (choosing 2 socks out of 10).

So:

  • Probability of the best-case scenario = 80 / 45 ≈ 1.78 (rounded to two decimal places).
  • Probability of the worst-case scenario = 360 / 45 = 8.

In the average case, you can calculate the expected number of complete pairs remaining by considering the probabilities:

  • Expected number of complete pairs = (Probability of best-case * Number of complete pairs in the best case) + (Probability of worst-case * Number of complete pairs in the worst case).
  • Expected number of complete pairs = (1.78 * 4) + (8 * 3) = 7.12 + 24 = 31.12.

So, in the average case, you should expect around 31 complete pairs of socks remaining.

0 0

Discussions

Post the discussion to improve the above solution.