Well i am giving a code , which finds the maximum sub of a subsequence in linear time, well if the problem specifies "at least L" about which i am not sure, then we need to modify the code slightly.

int MaxSubsequenceSum( const int A[ ], int N )

{
int ThisSum, MaxSum, j;

ThisSum = MaxSum = 0;
for( j = 0; j < N; j++ )
{
ThisSum += A[ j ];

if( ThisSum > MaxSum )
MaxSum = ThisSum;
else if( ThisSum < 0 )
ThisSum = 0;
}
return MaxSum;
}
moreover it doesnt gives the subsequence only the sum. The subsequence can also be found easily.

On 3/20/06, manu jose <[EMAIL PROTECTED]> wrote:
sorry i didnt read the second mail ( It came late to me) .. sincere appolo...

Actually the question was not clear ...

Thanks,
Manu

On 3/20/06, Mattia Merzi < [EMAIL PROTECTED]> wrote:

On 3/20/06, manu jose <[EMAIL PROTECTED]> wrote:
> 1) it says consecutive integers then how can you sort the array ?
if you read my first mail, I wrote: "if I understood correctly the problem",
that means: "maybe I'm wrong, maybe not, please give us some more
details".

>  2) How can u sort an array in O(logn) ???? it should be O(nlogn + L)
if you read my second mail, I wrote that it was a typo.

Maybe I'm wrong, nobody is perfect, but please, at least read _anything_
before answering. I think that here nobody needs to show his skills,
we just like to *try* to solve problems.

Thank you.





--
Manu Jose,
mob :09844467453
E-mail : [EMAIL PROTECTED]
-------------------------------------------------





--
Ajay kr. Mishra
http://ajay.mishra19.googlepages.com
IIT KGP
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to