Ashim,
looks good :)
nice work

On Mon, Sep 6, 2010 at 4:44 PM, Ashim Kapoor <[email protected]> wrote:

> int a[]={11,9,8,2,10,7,3,4,5}
> max_length = 1 ;
> current_length = 1;
> first_position=0 ;
> last_position = 0  ;
> first_position_max=0;
> // Sweep one to find the length of the longest subsequence.
>
> for ( i = 1 ; i < n ; i++ ) {
>               if ( a[i] > a[i-1] ) {
>                          last_position=i-1;
>                          current_length=last_position-
> first_position+1;
>                          max_length = current_length > max_length ?
> current_length : max_length;
>                          first_position_max = current_length > max_length ?
> first_position : first_position_max;
>                                first_position= i;
>               }
> }
>
> // Sweep two to print the longest subsequence.
>
> for ( i = first_position ; i < max_length ; i ++ ) {
>        cout<< a[i];
> }
>
>
> On Mon, Sep 6, 2010 at 2:01 PM, bittu <[email protected]> wrote:
>
>> u are given an array and u have to print the longest increasing
>> scattered subsequence...eg..{11,9,8,2,10,7,3,4,5}.
>>
>>
>> Solve it O(n);
>>
>>
>> --
>> 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]<algogeeks%[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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
---
Akash \m/

-- 
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.

Reply via email to