Re: [algogeeks] Facebook question!

2012-10-03 Thread Sudhir
A solution in java without arrays... class Combinations { static ArrayList words = new ArrayList(); static void getCombinations(ArrayList words) { for(int j=0;j No we don't need to care about repeated strings. :) Thanks for the > response folks. > > On Mon, Oct 1, 2012 at 8:42 PM, saurabh ag

Re: [algogeeks] Facebook question!

2012-10-01 Thread saurabh agrawal
Do we need to handle cases when the same string will appear again?? In that case we can sort individual array and remove duplicates. On Mon, Oct 1, 2012 at 9:54 AM, Rahul Singh wrote: > check this out.. > > #include > #include > using namespace std; > > void print_sets(string *s,int pos,int n,ch

Re: [algogeeks] Facebook question!

2012-10-01 Thread Rahul Singh
check this out.. #include #include using namespace std; void print_sets(string *s,int pos,int n,char *to_print) { if(pos==n) { return; } for(int i=0;i>n; string s[n]; for(int i=0;i>s[i]; } char *to_print = new char[n]; print_sets(s,0,n,to_print); } --

Re: [algogeeks] Facebook question!

2012-10-01 Thread Rahul Singh
check this out.. #include #include using namespace std; void print_sets(string *s,int pos,int n,char *to_print) { if(pos==n) { return; } for(int i=0;i>n; string s[n]; for(int i=0;i>s[i]; } char *to_print = new char[n]; print_sets(s,0,n,to_print); }

Re: [algogeeks] Facebook question!

2012-09-30 Thread atul anand
your debugged code :- error you were making was in tacking the row at each recursive call...and outer loop runs for 2...which should actually runs for all words #include #include #include using namespace std; string str[]={"hello", "how","a"}; #define words_len 3 void print_all(string sel, int row

Re: [algogeeks] Facebook question!

2012-09-30 Thread atul anand
my prev code was incorrect :- here is the correct code :- void combination(char str[3][100],int len,int row,int j) { static char prn[3]; int i=0,k=0,p=0; if(j==2) { prn[j]='\0'; printf("\n%s",prn); return; } for(p=ro

Re: [algogeeks] Facebook question!

2012-09-30 Thread atul anand
void combination(char str[2][100],int len,int row,int j) { static char prn[3]; int i=0,k=0,p=0; if(j==2) { prn[j]='\0'; printf("\n%s",prn); } for(p=row;p wrote: > Given 'n' arrays each of variable sizes. Write code to print all >

Re: [algogeeks] Facebook Question

2011-12-22 Thread SAMM
@UTKARSH SRIVASTAV Give the implemetation logic instead of the name of the DS . -- 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 a

Re: [algogeeks] Facebook Question

2011-12-21 Thread UTKARSH SRIVASTAV
use k-d tree On Thu, Dec 22, 2011 at 9:25 AM, atul anand wrote: > to find all points which lies on the same quadrant for a specific node(say > 1) , we have to check all nodes...rite?? > we have to find difference b/w 2 node(frome origin ) is less or greater > than distance b/w 2 nodes...rite?? >

Re: [algogeeks] Facebook Question

2011-12-21 Thread atul anand
to find all points which lies on the same quadrant for a specific node(say 1) , we have to check all nodes...rite?? we have to find difference b/w 2 node(frome origin ) is less or greater than distance b/w 2 nodes...rite?? so if i am not getting it wrong it wil be O(n^2) anyhow. On Thu, Dec 22, 2

Re: [algogeeks] Facebook Question

2011-12-21 Thread Algoose chase
Yup, it could be O(n^2) in the worst case. On Wed, Dec 21, 2011 at 1:59 PM, Carol Smith wrote: > @Algoose, in worst case, this is still O(n^2), ain't it? > > On Wed, Dec 21, 2011 at 12:50 PM, Algoose chase wrote: > >> Find the distance between each of the points and the origin(0,0) and sort >> th

Re: [algogeeks] Facebook Question

2011-12-21 Thread rahul
@harish What if all the points are in the same quadrant and and are equidistant from 0,0. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/NjysUthIqgYJ. To

Re: [algogeeks] Facebook Question

2011-12-21 Thread Carol Smith
@Algoose, in worst case, this is still O(n^2), ain't it? On Wed, Dec 21, 2011 at 12:50 PM, Algoose chase wrote: > Find the distance between each of the points and the origin(0,0) and sort > the points based on this distance. > Also, divide the points based on which quadrant they belong. If the >

Re: [algogeeks] Facebook Question

2011-12-21 Thread Algoose chase
Find the distance between each of the points and the origin(0,0) and sort the points based on this distance. Also, divide the points based on which quadrant they belong. If the difference between their distance(from origin) between 2 points is less and they belong to the same quadrant, then they a

[algogeeks] Facebook Question

2011-12-20 Thread SAMMM
You are given a list of points in the plane, write a program that outputs each point along with the three other points that are closest to it. These three points ordered by distance. The order is less then O(n^2) . For example, given a set of points where each line is of the form: ID x-coordinate