I had this question on the major exam
Q: devise an algorithm for generating all the r-combinations of a finite set when repetition is allowed.
my answer was a big space
Printable View
I had this question on the major exam
Q: devise an algorithm for generating all the r-combinations of a finite set when repetition is allowed.
my answer was a big space
Sql_lall: Perhaps your code might not take a lot of time for all combinations of 10 items three at a time.
Would you like to wait for the end of a program which copes with all combinations of 200 items 20 at a time?
1) I understand what the question is asking. :)
2) No, i wouldn't want to wait, but it says **devise** an algorithm, not implement it. :p
3) Actually, it would take longer to find all combinations of 200 objects 200 at a time with repetition allowed. :o :o
4) n objects, taken in r-combinations (r = 0 to n), WITHOUT repetition = 2^n different combinations. With repetition it takes even more. :eek:
All i'm saying is that if you had to make an algorithm (as the question asks), that is the way to do it. There is no possible way that you could make one fast enough dealing with large numbers that would be worth waiting for an answer!!! :cool: