Longest increasing sequence:
Given a sequence of n real numbers A(1) ... A(n), determine a subsequence
(not necessarily contiguous) of maximum length in which the values in the
subsequence form a strictly increasing sequence.

Input sequence :

 arr[]={2, 4, 3,-2,6,7};

Output sequence:

Number:7 index:5
Number:6 index:4
Number:4 index:1
Number:2 index:0

Code with O(n2) complexity
http://anandtechblog.blogspot.com/2010/07/longest-increasing-subsequence.html

Thanks,
Anand


On Thu, Dec 30, 2010 at 10:09 PM, suhash <suhash.venkat...@gmail.com> wrote:

> @bhupendra: I think you are talking about longest increasing subword.
> But, i think the question is longest increasing subsequence!
> definitions:
> subword: a contiguous sequence of characters. eg: 'abb' is a subword
> of 'cabber'
> subsequence: a sequence of characters of the original string, with
> order preserved. eg: 'abr' is a subsequence of 'cabber'
>
> But these two terms are used differently at different places!
> @Anand: Can you clarify what you meant(although i assume it's
> subsequence)!
>
> On Dec 31, 9:07 am, bhupendra dubey <bhupendra....@gmail.com> wrote:
> > It can be done in O(n) time.
> >
> > int start_index=0, longest_sequence=0
> >
> > traverse the sequence and increment 't' for every a[i+1]>a[i]
> > starting with zero till this holds true.
> >
> > assign 't' to longest_sequence
> >
> > assuming condition evaluates to false for a[k];
> > repeat the above step but assign 't' to longest_sequence only when
> > t>longest_sequence
> > also change start_index to 'k'
> >
> > do this for the whole array.
> >
> >
> >
> > On Fri, Dec 31, 2010 at 8:20 AM, Prabakaran N <prabaf...@gmail.com>
> wrote:
> > > You can use binary search
> >
> > > On 12/31/10, Anand <anandut2...@gmail.com> wrote:
> > > > Anyone know how to find longest increasing subsequence in O(nlogn)
> > > > complexity?
> >
> > > > --
> > > > You received this message because you are subscribed to the Google
> Groups
> > > > "Algorithm Geeks" group.
> > > > To post to this group, send email to algoge...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> <algogeeks%2bunsubscr...@googlegroups.com<algogeeks%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > > 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 algoge...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> <algogeeks%2bunsubscr...@googlegroups.com<algogeeks%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > bhupendra dubey
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to