# Question: note you are not required to write a program for...

###### Question details

*NOTE: You are NOT required to write a program for this
problem.* We wish to determine whether at least one
three-of-a-kind exists in a hand of N cards, where a
three-of-a-kind is three of the same value. Assume the cards have
values 1 – 13. For example, the hand with card values {11, 5, 11,
5, 5} does have at least one three-of-a-kind. **For each of
the following algorithms (A and B), find the simplified total Big-O
run time as a function of the number of cards (N). Explain your
answers based on each of the bulleted items and how they contribute
to the total run time.**

*Algorithm A:*

• Create a “count” array of size N that stores, for each card in the hand, the number of cards with that card’s value. It is initialized to be filled with 1’s because we know there is at least 1 of each card.

• For each card in the hand:

- Compare its value to the value of every other card.

- Each time the two values match, increment the corresponding “count” element for this card.

• If at least one value in the final “count” array is 3 or greater, there is a three-of-a-kind because at least 3 cards match that given card’s value.

Example: With card values {11, 5, 11, 5, 5}, the values in the “count” array would become {2, 3, 2, 3, 3}, and there is at least one three-of-a-kind.

*Algorithm B:*

• Create a “count” array of size 13 that stores, for each possible card value, the number of cards in the hand that have that value (1 – 13). It is initialized to be filled with 0’s

• For each card in the hand with value v, use v-1 as an index to increment the corresponding element in “count”. For example, if a card has value 13, increment “count” element #12.

• If at least one value in the final “count” array is 3 or greater, there is a three-of-a-kind because at least 3 cards have that given value.

Example: With card values {11, 5, 11, 5, 5}, the values in the “count” array would become {0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 2, 0, 0}, and there is at least one three-of-a-kind.