Difference between subarray, subset & subsequence

前端 未结 6 2217
鱼传尺愫
鱼传尺愫 2020-12-08 02:49

I\'m a bit confused between subarray, subsequence & subset

if I have {1,2,3,4}

then

subsequence can be {1,2,4} OR

6条回答
  •  隐瞒了意图╮
    2020-12-08 03:09

    In my opinion, if the given pattern is array, the so called subarray means contiguous subsequence.

    For example, if given {1, 2, 3, 4}, subarray can be

    {1, 2, 3}
    {2, 3, 4}
    etc.
    

    While the given pattern is a sequence, subsequence contain elements whose subscripts are increasing in the original sequence.

    For example, also {1, 2, 3, 4}, subsequence can be

    {1, 3}
    {1,4}
    etc.
    

    While the given pattern is a set, subset contain any possible combinations of original set.

    For example, {1, 2, 3, 4}, subset can be

    {1}
    {2}
    {3}
    {4}
    {1, 2}
    {1, 3}
    {1, 4}
    {2, 3}
    etc.
    

提交回复
热议问题