Recall & Review
beginner
What does the Union operation do in set operations?
Union combines all unique elements from two sets into one set, without duplicates.
Click to reveal answer
beginner
Explain the Intersect operation in set operations.
Intersect returns only the elements that are present in both sets.
Click to reveal answer
beginner
What does the Except operation do in set operations?
Except returns elements from the first set that are not in the second set.
Click to reveal answer
intermediate
In C#, which method is used to perform a union of two sets?
The
Union() method from System.Linq namespace is used to combine two sets without duplicates.Click to reveal answer
intermediate
How does
Intersect() behave when one of the sets is empty?The result is an empty set because there are no common elements.
Click to reveal answer
Which set operation returns elements only found in the first set but not in the second?
✗ Incorrect
Except returns elements from the first set that are not present in the second set.
What will
setA.Union(setB) return?✗ Incorrect
Union combines all unique elements from both sets.
If
setA is {1, 2, 3} and setB is {3, 4, 5}, what does setA.Intersect(setB) return?✗ Incorrect
Intersect returns elements common to both sets, which is {3}.
Which namespace must be included to use
Union(), Intersect(), and Except() in C#?✗ Incorrect
These methods are extension methods in the System.Linq namespace.
What is the result of
setA.Except(setB) if setA is empty?✗ Incorrect
Except returns elements in setA not in setB. If setA is empty, the result is empty.
Describe how the Union, Intersect, and Except operations work with examples in C#.
Think about combining, overlapping, and subtracting sets.
You got /4 concepts.
Explain why the System.Linq namespace is important for set operations in C#.
Consider where these methods come from.
You got /3 concepts.