Number of sub-sequences in a given sequence

前端 未结 12 651
傲寒
傲寒 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:57

    I started algorithm course very recently.

    I guess the more intuitive way of thinking about the answer is to think of an example.

    For example, we have A=(1,2,3) Then we may have 0 that's 1 way 1,2 or 3 that's 3 ways (1,2),(1,3),(2,3) that's 3 ways as well And (1,2,3) == that's 1 way again

    Total subsequence is 2^3 or 8. So the Generic formula is mC0+mC1+mC2,mC3+......mCm

    Please correct me if I'm wrong. I faced this problem minutes ago and this is how I thought about the intuitive formulation.

提交回复
热议问题