0
$\begingroup$

Is there some formula that allows us to calculate the number of calculations in a comparasion?

Suppose you have 5 numbers and want to calculate the number of comparisons :

  • Comparison 1: (1,2), (1,3), (1,4), (1,5), (2,3), (2,4), (2,5), (3,4), (3, 5), (4,5) : 10 Calculations

  • Comparison 2: (1,1), (1,2), (1,3), (1,4), (1,5), (2,2), (2,3), (2,4), (2,5), (3,3), (3,4), (3, 5), (4,4), (4,5), (5,5) : 15 Calculations

  • Comparison 3: (1,1), (1,2), (1,3), (1,4), (1,5), (2,1), (2,2), (2,3), (2,4), (2,5), (3,1), (3,2), (3,3), (3,4), (3, 5), (4,1), (4,2), (4,3), (4,4), (4,5), (5,1), (5,2), (5,3), (5,4), (5,5) : 25 Calculations

My Question: Are there some general formulas that can be used to "predict" in advance how many calculations will be required in each one of these comparisons? Could some formulas be used to extend this for "n" number of numbers? E.g. (1,1,1) ... (5,5,5)?

Thanks!

$\endgroup$
1
  • $\begingroup$ Yes there are such formulas. Check the wikipedia page for combinations. Perhaps someone will answer here and provide them. $\endgroup$ Commented Apr 26, 2022 at 22:46

1 Answer 1

2
$\begingroup$

In your examples, the first type of "comparisons" are called $\textbf{combinations}$. They are selections of items characterized by distinct elements, such that the order does not matter. This is why, for example, once we have considered $(1,2)$, we have not to consider $(2,1)$. The formula is

$$C_k^n=\displaystyle \binom{n}{k}=\frac{n!}{k!(n-k)!}$$

where $n$ is the total number of items and $k$ is the size of each subset.

The second type of comparisons are called $\textbf{combinations with repetitions}$. They are selections of items characterized by not necessarily distinct elements, again such that the order does not matter. Compared with the combinations without repetitions, these combinations allow for duplicates and are often indicated using the multiset symbol. The symbol and the formula are

$$\left(\!\!\displaystyle \binom{n}{k}\!\!\right) =\binom{n+k-1}{k}=\frac{(n+k-1)!}{n!(k-1)!}$$

The third type of comparisons shown in the OP are called $\textbf{permutations with repetitions}$. They are ordering of not necessary distinct $k$ objects chosen in a set of $n$ items, such that the order does not matter. The formula is simply

$$n^k$$

$\endgroup$
1
  • $\begingroup$ @ Anatoly: Thank you for your answer! $\endgroup$ Commented May 31, 2022 at 2:52

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.