User Tools

Site Tools


notes:discrete:fall2023:projects:set0

This is an old revision of the document!


SET0

Terms

member

Venn Diagram

set

universe

Set Logic

union

intersection

complement

difference

disjoint / mutually exclusive

What is disjoint

Disjoint in relation to set logic is when you are given two sets that do not share anything in common at all. Here is a simple example. you have a set A that consists of elements 1,2,3,4 and a set B that consists of elements 5,6,7,8. The two sets do not have any of the same elements thus the two sets are disjoint.

Here is also an example of two sets that are not disjoint. you are given set A which consists of 1,2,3,4 and set B which consists of 3,4,5,6. Because the two sets contain some of the same elements the sets are not disjoint.

How to show Disjoint using Venn Diagram

I found that displaying an example of disjoint sets was the easiest out of all the set logic. Instead of having two circles overlapping, you have two circles separated there for the sets are disjoint (not connected/share similar elements).

Simple Function for disjoint

When you are creating your disjoint function use the following as inspiration.

int disjointSets(int *set1, int size1, int *set2, int size2)
{
    // Iterate through set 1
    for (int i = 0; i < size1; i++)
    {
        // Check if the current element of set 1 is in set 2
        for (int j = 0; j < size2; j++)
        {
            if (set1[i] == set2[j])
            {
                return 0; // Not disjoint because the two sets have a common element
            }
        }
    }
    return 1; // Disjoint because the two sets do not have a common element
}
notes/discrete/fall2023/projects/set0.1699239115.txt.gz · Last modified: 2023/11/06 02:51 by wgates1