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
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
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);
}
--
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);
}
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
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
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
>
@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
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??
>
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
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
@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
@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
>
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
14 matches
Mail list logo