MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: how to get the longest ordered sub sequence of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103208] Re: [mg103158] how to get the longest ordered sub sequence of a list
  • From: a boy <a.dozy.boy at gmail.com>
  • Date: Thu, 10 Sep 2009 07:23:30 -0400 (EDT)
  • References: <200909090845.EAA05996@smc.vnet.net> <4AA79742.8020405@tue.nl>

Thank all! your answers are right!
However,what I need is the longest not-strict ordered items of a given list
L, not a segment of L. For example,
{1,8,2,4,3,5} -- ascending--> {1,2,4,5}
{1,8,2,4,3,5} --descending-->{8,4,3}

Because when I think this question (
http://groups.google.com/group/comp.soft-sys.math.mathematica/browse_thread/thread/f82401b1a517310c/9ca72a83a2313f50?lnk=gst&q=a.dozy.boy#9ca72a83a2313f50
):
For any integer k and 3^k, suppose 2^j is the closest to 3^k,
Gap[k]=| 3^k-2^j| is the subtraction .

Gap = Function[k, x = k*Log[2, 3];    Min[3^k - 2^Floor[x], 2^Ceiling[x] -
3^k]];
list=Table[{i, Gap[i]}, {i, 1, 5000}]

I want to find a non-strict decreasing items of {Gap[i]} .


On Wed, Sep 9, 2009 at 7:53 PM, Fred Simons <f.h.simons at tue.nl> wrote:

> a boy wrote:
>
>> how to get a (strict or not-strict)decreasing sub sequence of a list?
>>                                             ----------------
>>  increasing                                   ?
>>
>>
>>
>>
> lst=RandomInteger[{1,100}, {5000}];
>
> With[{sublists=Split[lst, #1<#2&]},
>    With[{m=Max[Length /@ sublists]},
>         Select[sublists, Length[#]==m&]]]
>
> {{3,19,22,33,51,66,89,95}}
>
> Fred Simons
> Eindhoven University of Technology
>


  • Prev by Date: Graphics > Drawing Tools > Get Coordinates Snow Leopard puzzlement
  • Next by Date: Re: Re: Transforming a list
  • Previous by thread: Re: how to get the longest ordered sub sequence of a
  • Next by thread: Re: how to get the longest ordered sub sequence of a list