[algogeeks] Adove Question.........

2011-07-22 Thread UMESH KUMAR
Hi

Given an array of size N that contain some elements, Write a program for
finding all possible subset of size R .

 n
i.e.   P
  r

Array :[1,2,3,4]

n=4,r=3;

Output should be:
{1,2,3},(1,2,4).{2,3,4},{...} possible 24 sets.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Adove Question.........

2011-07-22 Thread Puneet Gautam
@umesh: can R take any value from 1 to 3..?

On 7/22/11, UMESH KUMAR kumar.umesh...@gmail.com wrote:
 Hi

 Given an array of size N that contain some elements, Write a program for
 finding all possible subset of size R .

  n
 i.e.   P
   r

 Array :[1,2,3,4]

 n=4,r=3;

 Output should be:
 {1,2,3},(1,2,4).{2,3,4},{...} possible 24 sets.

 Thanks

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Adove Question.........

2011-07-22 Thread UMESH KUMAR
yes R is actually size of subset that is always less than or equal to Size
of the Array

i.e r=n

On Thu, Jul 21, 2011 at 11:16 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:

 @umesh: can R take any value from 1 to 3..?

 On 7/22/11, UMESH KUMAR kumar.umesh...@gmail.com wrote:
  Hi
 
  Given an array of size N that contain some elements, Write a program for
  finding all possible subset of size R .
 
   n
  i.e.   P
r
 
  Array :[1,2,3,4]
 
  n=4,r=3;
 
  Output should be:
  {1,2,3},(1,2,4).{2,3,4},{...} possible 24 sets.
 
  Thanks
 
  --
  You received this message because you are subscribed to the Google Groups
  Algorithm Geeks group.
  To post to this group, send email to algogeeks@googlegroups.com.
  To unsubscribe from this group, send email to
  algogeeks+unsubscr...@googlegroups.com.
  For more options, visit this group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to
 algogeeks+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Adove Question.........

2011-07-22 Thread Piyush Sinha
initial call

subset(a,n,r,0,0);
printf(%d,count);//to know the value of nPr (no of subsets)
*
void subset(int a[],int n,int r,int j,int ind)
{
 int i;
 if(ind==r)
 {
   printf({);
   for(i=0;iind;i++)
printf(%d ,a[i]);
   printf(}\n);
   count++;
 }
 else if (indr)
 {
  for(i=j;in;i++)
  {
 swap(a[i],a[j]);
 subset(a,n,r,j+1,ind+1);
 swap(a[i],a[j]);
  }
 }
}*

-- 
*Piyush Sinha*
*IIIT, Allahabad*
*+91-7483122727*
* https://www.facebook.com/profile.php?id=10655377926 NEVER SAY
NEVER
*

-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.