Polymerase
Polymerase

Reputation: 6811

Is empty set a subset of a NonEmpty set?

Let's imagine a function bigset.containSubset(smallset) which returns true/false

How should the result be for the following edge cases:

If I define arbitrarily "if the intersection of both sets gives a result identical than the smaller set, then smallset is a subset". Then the answer is true for both cases above. Is this a correct assumption?

scala> Set().intersect(Set())
res1: scala.collection.immutable.Set[Nothing] = Set()

scala> Set(1,2,3).intersect(Set())
res2: scala.collection.immutable.Set[Int] = Set()

Upvotes: 0

Views: 748

Answers (1)

Jessica Larson
Jessica Larson

Reputation: 66

As far as I learned it, the empty set is a subset of all sets. So if both sets are empty than they are the same set. If bigset is nonEmpty and smallset is empty, then smallset is a subset of bigset.

Upvotes: 5

Related Questions