Number of sub-sequences in a given sequence

前端 未结 12 650
傲寒
傲寒 2021-01-30 18:18

If I am given a sequence X = {x1,x2,....xm}, then I will have (2^m) subsequences. Can anyone please explain how can I arrive at this formula intuitivel

12条回答
  •  长发绾君心
    2021-01-30 18:55

    For any sequence X = {x1,x2,....xm}, there will be (2^m) sub-sequences, because you can "choose" sub-sequences of length 0,1,2,...,m ,i.e., mathematically it is

    "C(m,0) + C(m,1) + ... C(m,m)" which leads to 2^m.

    For e.g., say the string is "abc", then

    C(3,0) = 1, ""

    C(3,1) = 3, "a", "b", "c"

    C(3,2) = 3, "ab", "bc", "ac"

    C(3,3) = 1, "abc"

    number of subsequences are 8 i.e., 2^3.

    For more details visit http://en.wikipedia.org/wiki/Binomial_coefficient#Series_involving_binomial_coefficients

提交回复
热议问题