I have k items, need to place them in n spots(n>k). In how many ways can this be done?
Example -
for k=2 and n=4,
these are the possibilities assuming items to be like this [1,2]
12--
1-2-
1--2
-12-
-1-2
--12
I am unable to find a general solution. Please help. This is not a homework/assignment; I am stuck as this is a sub-part of a programming problem.
I think you have $(n-k)$ empty spaces you need to place between, before, or after the $k$ items.
So, how many ways can you place $(n-k)$ spaces in $(k+1)$ bins. Which is $$(k+1)+(n-k)-1\choose {(n-k)}$$ In your example: $${(2+1)+(4-2)-1\choose {(4-2)}}={4\choose 2}=6$$ ETA: which simplifies to$${n\choose{n-k}}={n\choose k}$$ as abiessu commented above.