[go: up one dir, main page]

0% found this document useful (0 votes)
6 views3 pages

Set Operators

The document explains various set operators including union, intersection, difference, and symmetric difference using sets A and B. It also covers additional operators for checking subset, superset, equality, and membership within sets. Examples are provided to illustrate each operator's functionality.

Uploaded by

apurbajoy7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Set Operators

The document explains various set operators including union, intersection, difference, and symmetric difference using sets A and B. It also covers additional operators for checking subset, superset, equality, and membership within sets. Examples are provided to illustrate each operator's functionality.

Uploaded by

apurbajoy7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Set Operators

• The operators are given in the right hand side table


• Here we are taking the following sets and performing di erent set operators.

s = { 1,2,3,4,5,6,7,8,9,10 }

A = { 1,2,3,5,7 } B = { 5,7,9,10,11 }

• Union means combining both sets and removing duplicates

C=A|B => A | B = { 1,2,3,5,7,9,10,11 }

C - Taking result of A , B in var C


| - pipe / union symbol

• Intersection means giving common elements

C=A&B => A & B = { 5,7 }

C - Taking result of A , B in var C


& - Intersection symbol

• Di erence of A - B means take all elements of A except those common in B

C=A-B => A - B = { 1,2,3 }

• Symmetric Di erence means take all elements of A and B except those common to both sets

C=A^B => A ^ B = { 1,2,3,9,10,11 }

C - Taking result of A , B in var C


^ - Symmetric di erence
ff
ff
ff
ff
#union

#intersection

#di erence

#symmetric di erence

• Now let us check other operators.


• < , > are useful for checking proper subset (or) proper superset
• <= ,>= they consider equal sets as well while checking subset and superset
• == they check if two sets are equal or not
• != they check if two sets are not equal

#11 Is in B but not in S so that’s why false

• in , not in are also know as membership operators


• They check if an element is present in a set or not and return boolean type as result.
ff
ff
Note :

• If you store the result of A | B in A, then the result will be go in A itself. So, You can write this as

A | B ( same as A = A | B )
A & B ( same as A = A & B )
A - B ( same as A = A - B)

You might also like