Number of sub-sequences in a given sequence

前端 未结 12 654
傲寒
傲寒 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-30 18:47

    To anyone who is actually looking for a substring (as the title or URL might lead you to believe):

    Subset: 2^n (Order doesn't matter in sets)
    Subsequence: 2^n (Since we keep the original ordering, this is the same.)
    Substring: n(n+1) * 1/2 (Elements must be consecutive)
    

提交回复
热议问题