Set - Difference
Table of Contents
1 - About
difference is an operation between two sets.
2 - Articles Related
3 - Type
3.1 - Asymmetric
In a asymmetric difference, the difference element come only from the first set.
The asymmetric difference | ||||||
---|---|---|---|---|---|---|
of | 1 | 2 | 3 | 4 | ||
and | 3 | 4 | 5 | 6 | ||
is | 1 | 2 |
Implementation:
- loop over setA
- does setB has element of setA
- if yes, return the element
3.2 - Symmetric
The symmetric difference is the union of the two asymmetric difference
- asymmetric diff SetA to SetB
- asymmetric diff SetB to SetA
The symmetric difference | ||||||
---|---|---|---|---|---|---|
of | 1 | 2 | 3 | 4 | ||
and | 3 | 4 | 5 | 6 | ||
is | 1 | 2 | 5 | 6 |