Table of Contents

discrete Keyword 2

Intersection

Definition

Two sets A and B is the set that contains all elements of A that also belong to B (or equivalently, all elements of B that also belong to A), but no other elements.

Example:

  The intersection of the sets {1, 2, 3} and {2, 3, 4} is {2, 3}.

References

discrete Keyword 2 Phase 2

cartesian product

Definition

Cartesian Product is making one set that takes one from a set and pairs it with one value from another set. This is done for each of the values in each set. Example:

References

Demonstration

lab46:~$ ./cartesian

Enter Array Size For Array A: 3
Enter Array A Elements:
1
2
4

Enter Array Size For Array B: 3
Enter Array B Elements:
5
7
9

Cartesian Product Of Array A & B:
A = {1,2,4}  &  B = {5,7,9}
A x B = {1,2} x {2,7}  x {4,9} = {(1,5), (1,7), (1,9), (2,5), (2,7), (2,9), (4,5), (4,7), (4,9)}
B x A = {4,9} x {2,7} x {1,2} = {(4,9), (4,7), (4,5), (2,9), (2,7), (2,5), (1,9), (1,7), (1,5)}