Clever Geek Handbook
📜 ⬆️ ⬇️

Largest alternating subsequence

In combinatorics, probability theory, and computer science, the problem of the greatest alternating subsequence is to find a subsequence of the greatest length of a given sequence such that its elements are arranged in an alternating manner.

Let bex={xone,x2,...,xn} {\ displaystyle \ mathbf {x} = \ {x_ {1}, x_ {2}, \ ldots, x_ {n} \}} {\ displaystyle \ mathbf {x} = \ {x_ {1}, x_ {2}, \ ldots, x_ {n} \}} Is a sequence of different real numbers, then a subsequence{xione,xi2,...,xik} {\ displaystyle \ {x_ {i_ {1}}, x_ {i_ {2}}, \ ldots, x_ {i_ {k}} \}} {\ displaystyle \ {x_ {i_ {1}}, x_ {i_ {2}}, \ ldots, x_ {i_ {k}} \}} alternating if

xione>xi2<xi3>⋯xikandone≤ione<i2<⋯<ik≤n.{\ displaystyle x_ {i_ {1}}> x_ {i_ {2}} <x_ {i_ {3}}> \ cdots x_ {i_ {k}} \ qquad {\ text {and}} \ qquad 1 \ leq i_ {1} <i_ {2} <\ cdots <i_ {k} \ leq n.} {\ displaystyle x_ {i_ {1}}> x_ {i_ {2}} <x_ {i_ {3}}> \ cdots x_ {i_ {k}} \ qquad {\ text {and}} \ qquad 1 \ leq i_ {1} <i_ {2} <\ cdots <i_ {k} \ leq n.}

Similarlyx {\ displaystyle \ mathbf {x}} \ mathbf {x} reverse alternating if

xione<xi2>xi3<⋯xikandone≤ione<i2<⋯<ik≤n.{\ displaystyle x_ {i_ {1}} <x_ {i_ {2}}> x_ {i_ {3}} <\ cdots x_ {i_ {k}} \ qquad {\ text {and}} \ qquad 1 \ leq i_ {1} <i_ {2} <\ cdots <i_ {k} \ leq n.} {\ displaystyle x_ {i_ {1}} <x_ {i_ {2}}> x_ {i_ {3}} <\ cdots x_ {i_ {k}} \ qquad {\ text {and}} \ qquad 1 \ leq i_ {1} <i_ {2} <\ cdots <i_ {k} \ leq n.}

Let beasn(x) {\ displaystyle {\ rm {as}} _ {n} (\ mathbf {x})} {\ displaystyle {\ rm {as}} _ {n} (\ mathbf {x})} denotes the length (number of elements) of the largest alternating subsequence of the sequencex {\ displaystyle \ mathbf {x}} \ mathbf {x} . For example, if we consider some permutation of the numbers 1,2,3,4,5, we get

  • asfive(one,2,3,four,five)=2{\ displaystyle {\ rm {as}} _ {5} (1,2,3,4,5) = 2} {\ displaystyle {\ rm {as}} _ {5} (1,2,3,4,5) = 2} ;
  • asfive(one,five,3,2,four)=four,{\ displaystyle {\ rm {as}} _ {5} (1,5,3,2,4) = 4,} {\ displaystyle {\ rm {as}} _ {5} (1,5,3,2,4) = 4,} because 1,5,3,4 and 1,5,2,4 and 1,3,2,4 are alternating, and there is no alternating subsequence of more elements;
  • asfive(five,3,four,one,2)=five,{\ displaystyle {\ rm {as}} _ {5} (5,3,4,1,2) = 5,} {\ displaystyle {\ rm {as}} _ {5} (5,3,4,1,2) = 5,} because 5,3,4,1,2 alternating.

Effective Algorithm

The problem of the greatest alternating subsequence is solved in timeO(n) {\ displaystyle O (n)} O(n) wheren {\ displaystyle n} n Is the length of the original sequence.

Probabilistic estimates

If ax {\ displaystyle \ mathbf {x}} \mathbf {x} - random permutation of numbersone,2,...,n {\ displaystyle 1,2, \ ldots, n} {\displaystyle 1,2,\ldots ,n} andAn≡asn(x) {\ displaystyle A_ {n} \ equiv {\ rm {as}} _ {n} (\ mathbf {x})} {\displaystyle A_{n}\equiv {\rm {as}}_{n}(\mathbf {x} )} , then it can be shown that

E[An]=2n3+one6andVar⁡[An]=eightn45-13180.{\ displaystyle E [A_ {n}] = {\ frac {2n} {3}} + {\ frac {1} {6}} \ qquad {\ text {and}} \ qquad \ operatorname {Var} [A_ {n}] = {\ frac {8n} {45}} - {\ frac {13} {180}}.} {\displaystyle E[A_{n}]={\frac {2n}{3}}+{\frac {1}{6}}\qquad {\text{and}}\qquad \operatorname {Var} [A_{n}]={\frac {8n}{45}}-{\frac {13}{180}}.}

Moreover, withn→∞ {\ displaystyle n \ rightarrow \ infty} n \rightarrow \infty random valueAn {\ displaystyle A_ {n}} A_{n} centered, normalized, its distribution tends to normal.

See also

  • Largest increasing subsequence
  • Largest overall subsequence
  • Alternating permutation


Source - https://ru.wikipedia.org/w/index.php?title=Largest_sequent_sequence&oldid=99370642


More articles:

  • Malaysian Football Championship
  • Walls
  • Belina-Prazhmovsky, Vladislav
  • Skobeltsyno
  • Two-tone carnation
  • Polynsky, Sergey Mikhailovich
  • 1950 European Athletics Championships
  • Palestine Football Championship
  • Kara-Archa (Talas region)
  • Heaven on Earth (Belinda Carlisle album)

All articles

Clever Geek | 2019