for(i=0;i<26;i++)
array[i][0]=1;
for(n=0;n<26;n++)
{
for(j=0;j<26;j++)
{
for(i=j+1;i<26;i++)
{
temp+=array[i][n];
}
array[j][n+1]=temp;
temp=0;
}
}
for(i=0;i<26;i++)
array[i][0]=1;
you can cout to get the array.
and this following function gets the lex code from the matrix constructed:
int getlex(string line)
{
int i=0,j=0;
i=line.length();
int n=0;
int temp=0;
int pivot=0;
int flag = 0;
for(j=0;j<i-1;j++) {
if(line[j]>=line[j+1]) {
flag=1;
}
}
if(flag == 0) {
for(j=i-1;j>-1;j--)
{
pivot=(int)line[j]-97;
while(pivot>-1)
{
temp+=array[pivot][n];
pivot--;
}
n++;
}
}
return temp;
}
On 10/22/06, preeti <[EMAIL PROTECTED]> wrote:
ya, i got it..... thanx.....but one think which i dont understand that
is that though we hv a direct fromula for calculating thru your algo
but what i think is that while programming it might be difficult to
maintain a matrix with no fixed size as characters are though 26 but
length of string is not fixed ...in ur matrix the logic of 2nd and 3rd
column i cudnt understand so before knowing that i cant probably say
how can u replace that char with a no. of a certain position and add
it.... if u can make it then make a program in c/c++ for ur algo for my
better understanding....
thanx
--
Rajarshi Chowdhury
M.Tech, CSE
IIT Roorkee
([EMAIL PROTECTED])
http://chowdhuryrajarshi.blogspot.com
"It is not our abilities that show what we truly are ... it is our choices"
Join Dumbledore's Army at http://groups.google.co.in/group/dumbledore
--~--~---------~--~----~------------~-------~--~----~
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-beta.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---
