GATE CSE
First time here? Checkout the FAQ!
x
+5 votes
116 views
  • Using numbers from  S = $\left \{ 1,2,3,4.......n \right \}$
  • We can use maximum up to m numbers to form a set using numbers from S. Repetition of numbers allowed.
  • How many ways we can form a set such that,  $\sum x_i = K$.  Where $K$ is another positive integer. Where $x_i$ are the elements belong $S$ that are included in the newly formed set.

For example :

  • S = $\left \{ 1,2,3,4,5...11,12 \right \}$
  •  m = $4$
  • if $K = 6$
  • Then possible few possible sets are $\{2,4\}, \;\; \{1,3,2\}, \;\; \{1,4,1\},\;\; \{1,1,1,3\}$ etc.
  • $\{1,1,1,1,2\}$ is not valid set for example.
  • Now how many such sets for a particular instance of the problem ? with 
  • S = $\left \{ 1,2,3,4,5,6...12 \right \}$ , $m = 5$, $K = 8$ ?
  • If there is any generic idea ?
  • Ordered / Unordered both the cases !
asked in Combinatory by Veteran (36.5k points)  
edited by | 116 views
Do we have to count {1,2,3} and {1,3,2} different ?
no need to count ..updated !
After a little bit of work around I ended up with 16 as the answer to this specific question. Let me know if that is right, I will then share my approach.

Ii don't know share your approach!

Actually, I need the ordered collection only ..sorry for describing the QS as an unordered set. @kapil asked earlier about this.


will this recurrence work ? for ordered collection?

f(m,k) = no of ordered collection using the numbers from S

$f(m,k) = \begin{cases} 1 \qquad m=0 , k = 0\\ \\ 0 \qquad m=0 , k > 0\\ \\ \sum_{x_i \; }^{\{\{0\} \cup S \}\;} f(m-1,k-x_i) \quad m \geq 1 , (k+x_i) \geq 0 \\ \end{cases}$

Please log in or register to answer this question.

Top Users Jan 2017
  1. Debashish Deka

    8618 Points

  2. sudsho

    5402 Points

  3. Habibkhan

    4718 Points

  4. Bikram

    4522 Points

  5. Vijay Thakur

    4468 Points

  6. saurabh rai

    4222 Points

  7. Arjun

    4136 Points

  8. santhoshdevulapally

    3742 Points

  9. Sushant Gokhale

    3576 Points

  10. GateSet

    3398 Points

Monthly Topper: Rs. 500 gift card

19,188 questions
24,075 answers
52,997 comments
20,314 users