store strings in array of pointers...char *str[100]
str[0]....str[99]
make every possible suffix and prefix for each string...
for ex. str[0]="ababa"
possible suffix={ababa,abab,aba,ab,a}
possible prefix={ababa,baba,aba,ba,a}
so make a structure for storing these suffix and prefixes and their count in
other strings
struct node
{
char str[];
int count;
struct node *next;
}
now save these suffix and prefixes in these nodes and initialize their
count with 0....
after making sets for all strings...count their occurences in other nodes
with help of loops...
and then check for largest count...
...
On Sun, Sep 18, 2011 at 5:24 PM, pooja <[email protected]> wrote:
>
> sorry.. i meant the longest common substring..
> eg. consider 4 string.. ababa , bab , babba, abab
> so the longest common substring is bab.
>
> On Sep 18, 4:40 pm, Yogesh Yadav <[email protected]> wrote:
> > struct string_node
> > {
> > char str[];
> > int length;
> > struct string_node *ptr;
> >
> > }
> >
> > now traverse the strings and saving strings in "str[]",their length in
> > "length" and point it to next string_node....
> >
> > ....
> >
> >
> >
> >
> >
> >
> >
> > On Sun, Sep 18, 2011 at 4:47 PM, pooja <[email protected]> wrote:
> > > Can some one please help me with this..
> > > the problem is to find the longest substring in a list of around 100
> > > strings..??
> > > any idea..
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.