Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
861 views
in Technique[技术] by (71.8m points)

arrays - Difference between subarray, subset & subsequence

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

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

then

subsequence can be {1,2,4} OR {2,4} etc. So basically I can omit some elements but keep the order.

subarray would be( say subarray of size 3)

{1,2,3}
{2,3,4} 

Then what would be the subset?

I'm bit confused between these 3.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.7k users

...