Calculating Possible Combinations in 2 Vectors

In summary, the conversation discusses a programming project where the individual wants to know how many possible combinations can exist in a particular situation with two vectors. They determine that there are 9 spots and 5 numbers to place in them, resulting in a total of 15,120 permutations. The conversation also explains the difference between permutations and combinations.
  • #1
King
43
0
Hi all,

I am working on a programming project and want to know how many possible combinations can exist in a particular situation, but I have no idea how to work it out. It isn't homework, I just want to know because I am sure it is a VERY large number and want to make a point.

There are 2 vectors, one vector is one dimensional and is, say, 5 in length with values in it: [ 1 | 2 | 3 | 4 | 5 ] and the second vector is two dimensional and empty (to be filled with the numbers in the one dimensional vector), say like so:
+---------+
| - | - | - |
| - | - | - |
| - | - | - |
+---------+
How would I go about working out working out how many combinations of those 5 numbers can be placed in the above two dimensional vector?
eg. one would be:
+---------+
| 1 | 2 | 3 |
| 4 | 5 | - |
| - | - | - |
+---------+
another:
+---------+
| 1 | 3 | 2 |
| 4 | 5 | - |
| - | - | - |
+---------+

Thank you for any help :smile:
 
Physics news on Phys.org
  • #2
There are 9 spots and 5 numbers to place in them. First pick 5 of the spots and then calculate the permutation of the 5 numbers in those 5 spots. I think this should be the answer, unless I am misunderstanding completely.

[tex]\binom{9}{5} 5! = 15,120[/tex]

This can also be calculated as the number of 5-permutations of 9 objects, since the first number would have 9 possible spots to occupy, the second would have 8 possibilities, etc...

P(9,5) = 15,120
 
  • #3
Thanks for the quick reply! But what are permutations? I see that the 120 came from the 5! but I'm not sure what P(9,5) is... :confused:
 
  • #4
King said:
Thanks for the quick reply! But what are permutations? I see that the 120 came from the 5! but I'm not sure what P(9,5) is... :confused:

P(a, b) is the answer to your question with 9 slots in the matrix and 5 in the vector. It was defined on the spot, it's not a usual symbol.
 
  • #5
The intermediate step is P(9,5) = 9*8*7*6*5 = 15,120.

Permutations are similar to combinations except in permutations, the order matters. In combinations, the order does not.
 
  • #6
Thank you very much for the help :smile:
 

FAQ: Calculating Possible Combinations in 2 Vectors

What is the formula for calculating possible combinations in 2 vectors?

The formula for calculating possible combinations in 2 vectors is nCr = n! / (r!*(n-r)!), where n is the total number of items in the vectors and r is the number of items to be selected.

How do you determine the total number of items in the vectors?

The total number of items in the vectors can be determined by adding the number of items in each vector together. For example, if vector A has 4 items and vector B has 3 items, the total number of items would be 7.

What does the "n" and "r" stand for in the formula?

In the formula, "n" represents the total number of items in the vectors and "r" represents the number of items to be selected.

Can the order of items in the vectors affect the number of possible combinations?

Yes, the order of items in the vectors can affect the number of possible combinations. For example, if the vectors contain the same items but in a different order, they would have different combinations. This is known as permutations.

How can you use the formula to calculate the number of combinations if there are more than 2 vectors?

The formula can be modified to accommodate for more than 2 vectors by using the formula nCr = (n1+n2+...+nk)! / (r1!r2!...rk!), where n1, n2,...,nk are the total number of items in each vector and r1, r2,...,rk are the number of items to be selected from each vector.

Similar threads

Replies
2
Views
1K
Replies
14
Views
1K
Replies
12
Views
1K
Replies
18
Views
2K
Replies
2
Views
1K
Replies
7
Views
1K
Replies
6
Views
1K
Back
Top