Bachelor of Science in Computer Science
Course ContentSets
Habari! Welcome to the World of Sets!
Imagine you're at a busy market, like Toi Market in Nairobi or Kongowea in Mombasa. You see stalls neatly arranged: one for *matunda* (fruits), another for *mboga* (vegetables), and another for *nafaka* (cereals). The sellers have grouped their items to make it easy for you to find what you need. In mathematics, we do the exact same thing! This powerful idea of grouping things is called Sets.
So, take a deep breath, grab your notebook, and let's explore this simple but incredibly important topic that is a building block for so much in mathematics and computer science. Ready? Let's go!
What Exactly is a Set?
A Set is simply a collection of well-defined, distinct objects. Let's break that down:
- Well-defined: This means we can tell for sure whether an object belongs to the collection or not. "The set of tall students" is not well-defined (how tall is "tall"?), but "The set of students over 170cm" is well-defined.
- Distinct: Each object in a set must be unique. We don't list the same item twice.
The objects in a set are called elements or members.
Kenyan Example:
Let's create a set of some Kenyan mobile network providers. We'll call this set M.
The elements would be Safaricom, Airtel, and Telkom.
We write this using curly braces { }.
M = {Safaricom, Airtel, Telkom}
The order of elements doesn't matter. {Airtel, Safaricom, Telkom} is the exact same set!
Important Lingo: The Language of Sets
To be a pro, you need to know the language. Here are some key terms:
- Cardinality: This is just a fancy word for the number of elements in a set. We write it with two vertical bars, like
|A|. For our set M above, the cardinality is 3.|M| = 3 - The Empty Set (or Null Set): A set with no elements at all. It's represented by
{ }or the symbol∅.Example: The set of all lions that can fly. Obviously, there are none! So,
FlyingLions = ∅. - The Universal Set (U): This is the "big picture" set that contains all possible elements for a particular problem. If we are discussing different types of fruits, our Universal Set might be U = {apple, banana, mango, orange, avocado}.
- Subsets (⊆): A set A is a subset of set B if every element of A is also in B. Think of it like a club within a school. The Drama Club is a subset of all school clubs.
A proper subset (⊂) is a subset that is not equal to the original set. In our example, A is also a proper subset of B (A ⊂ B) because B has an element (Telkom) that A does not.Let A = {Safaricom, Airtel} Let B = {Safaricom, Airtel, Telkom} Here, A is a subset of B. We write this as: A ⊆ B
Image Suggestion: An overhead shot of a vibrant Kenyan market stall. The stall is divided into neat sections. One section has a pile of mangoes, another has bananas, and a third has avocados. A sign above the stall reads "Matunda Bora". The image should be colourful and busy, capturing the market energy.
Let's Get Operational: Playing with Sets
This is where the fun begins! We can perform operations on sets, just like we can with numbers (+, -, ×, ÷).
1. Union (∪) - "Bringing Everything Together"
The union of two sets, A and B, is a new set containing all the elements from both sets. Think of it as a merger. If an element is in both sets, we only list it once.
Scenario: You're making Githeri. Your recipe needs items from Set G. Your friend is making Sukuma Wiki, needing items from Set S.Notice "Onion" is listed only once!G = {Maize, Beans, Onion} S = {Sukuma, Onion, Tomato} The union, G ∪ S, is the complete shopping list for both of you: G ∪ S = {Maize, Beans, Onion, Sukuma, Tomato}
2. Intersection (∩) - "What Do We Have in Common?"
The intersection of two sets, A and B, is a new set containing only the elements that are in both A and B.
Scenario: Let's use our Githeri (G) and Sukuma Wiki (S) sets again. What ingredient do both recipes share?G = {Maize, Beans, Onion} S = {Sukuma, Onion, Tomato} The intersection, G ∩ S, is the item you both need: G ∩ S = {Onion}
3. Difference (-) - "Yours but Not Mine"
The difference A - B is the set of elements that are in A but not in B.
Scenario: What ingredients are needed for Githeri but NOT for Sukuma Wiki?G = {Maize, Beans, Onion} S = {Sukuma, Onion, Tomato} The difference, G - S, is: G - S = {Maize, Beans}
4. Complement (A') - "Everything Else"
The complement of a set A (written as A' or Ac) is the set of all elements in the Universal Set (U) that are not in A.
Scenario: Let's say our Universal Set U for the day's cooking is all the ingredients available.U = {Maize, Beans, Onion, Sukuma, Tomato, Salt} G = {Maize, Beans, Onion} The complement of G, written G', is everything in U that is NOT in G: G' = {Sukuma, Tomato, Salt}
Visualizing with Venn Diagrams
Sometimes, a picture is worth a thousand words. A Venn diagram helps us see the relationships between sets using overlapping circles inside a box (the box represents the Universal Set).
Union (A ∪ B) - Everything Shaded
_________________________
| U |
| ****** ****** |
| ** * ** |
| * A *** B * |
| * * * |
| * * * |
| ** * ** |
| ****** ****** |
|_________________________|
Intersection (A ∩ B) - Only the Overlap is Shaded
_________________________
| U |
| ______ ______ |
| / * \ |
| ( A *** B ) |
| ( * ) |
| \ * / |
| \______*______/ |
| * |
|_________________________|
Difference (A - B) - Only the 'A' part is Shaded
_________________________
| U |
| ****** ______ |
| ** ( \ |
| * A ) B ) |
| * ( ) |
| * ( / |
| **______\______/ |
| ****** |
|_________________________|
Image Suggestion: A clean and colourful infographic showing four Venn diagrams side-by-side. Each diagram illustrates one of the four main set operations (Union, Intersection, Difference, Complement) with clear labels and distinct colour shading (e.g., Set A is blue, Set B is yellow, the intersection is green).
Tusonge Mbele: Let's Move Forward!
Congratulations! You've just learned the fundamentals of sets. It might seem abstract, but you'll see it pop up everywhere – from searching for information on Google (which uses set operations to filter results) to organizing data in spreadsheets and databases.
The key is to practice. Try creating sets from your daily life: the set of your favourite subjects, the set of counties you have visited, or the set of artists on your music playlist. Then, see if you can perform union and intersection operations. You are building a powerful mental tool. Keep up the great work!
Pro Tip
Take your own short notes while going through the topics.