1 Basic Discrete Structures

Discrete Structures ยท Unit 1 ยท 7 hrs

Basic Discrete Structures

Exam-focused notes for Basic Discrete Structures (Discrete Structures, CSC165): what the TU syllabus asks and how it has actually been tested, with 9 solved past questions from this unit.

Basic Discrete Structures in short

This chapter builds the vocabulary that the rest of discrete structures is written in: sets and the operations on them, functions and how they classify mappings between sets, the fuzzy generalisation of a set, and sequences with the summation notation used to add up their terms.

Basic Discrete Structures: notes

Sets

A set is an unordered collection of distinct objects, called its elements. Repeating an element or reordering a listing never changes the set. A set can be written in roster (tabular) form, by listing its elements inside braces, for example $A = {a, e, i, o, u}$, or in set builder notation, by stating the property its elements share, for example $A = {x : x \text{ is a vowel of the English alphabet}}$. Membership is written $x \in S$ and non-membership $x \notin S$; for $S = {1, 1.2, 1.7, 2}$, $1 \in S$ but $1.5 \notin S$.

Some sets recur so often that they have standard names: $\mathbb{N}$ (natural numbers, ${1, 2, 3, \ldots}$), $\mathbb{Z}$ (integers), $\mathbb{Z}^+$ (positive integers), $\mathbb{Q}$ (rationals), $\mathbb{R}$ (reals) and $\mathbb{W}$ (whole numbers, ${0, 1, 2, \ldots}$).

The cardinality of a set $S$, written $|S|$, is the number of elements it contains; an infinite set has infinite cardinality. Comparing cardinalities of two sets $X$ and $Y$ connects directly to functions between them: $|X| = |Y|$ exactly when a bijective function exists from $X$ to $Y$, $|X| \leq |Y|$ exactly when an injective function exists from $X$ to $Y$, and $|X| < |Y|$ when that injective function cannot be made bijective.

Sets and Subsets

A set $X$ is a subset of $Y$, written $X \subseteq Y$, if every element of $X$ is also an element of $Y$. It is a proper subset, written $X \subset Y$, if additionally $X \neq Y$, that is $|X| < |Y|$. Every set is a (non-proper) subset of itself.

The universal set $U$ is the set of all objects under discussion in a given context; every other set considered is implicitly a subset of $U$. The empty (null) set, written $\emptyset$, contains no elements and has cardinality $0$, so it is finite. A singleton set contains exactly one element, for instance ${8}$.

Two sets are equal if they contain exactly the same elements, regardless of order, for example ${1, 2, 6} = {6, 1, 2}$. Two sets are equivalent if they merely have the same cardinality, for example ${1, 2, 6}$ and ${16, 17, 22}$ are equivalent because both have three elements, even though they are not equal. Two sets are overlapping if they share at least one common element, and disjoint if they share none. For disjoint sets, $A \cap B = \emptyset$ and consequently $n(A \cup B) = n(A) + n(B)$; for overlapping sets this identity needs a correction term, which is the subject of the inclusion-exclusion principle below.

Power Set

The power set of a set $S$, written $P(S)$, is the set of all subsets of $S$, including $\emptyset$ and $S$ itself. If $|S| = n$, then $|P(S)| = 2^n$, since each element is independently either included or excluded from a given subset.

For $S = {a, b, c, d}$, listing subsets by size gives one subset of size $0$ (namely $\emptyset$), four of size $1$, six of size $2$, four of size $3$, and one of size $4$, for $1+4+6+4+1 = 16 = 2^4$ subsets in total: $$P(S) = {\emptyset, {a},{b},{c},{d}, {a,b},{a,c},{a,d},{b,c},{b,d},{c,d}, {a,b,c},{a,b,d},{a,c,d},{b,c,d}, {a,b,c,d}}.$$ The power set of the empty set is not empty: $P(\emptyset) = {\emptyset}$, so $|P(\emptyset)| = 2^0 = 1$.

Cartesian Product

The Cartesian product of sets $A_1, A_2, \ldots, A_n$, written $A_1 \times A_2 \times \cdots \times A_n$, is the set of all ordered $n$-tuples $(x_1, x_2, \ldots, x_n)$ with $x_i \in A_i$ for every $i$. For two sets $A = {a, b}$ and $B = {1, 2}$, $$A \times B = {(a,1),(a,2),(b,1),(b,2)}, \qquad B \times A = {(1,a),(1,b),(2,a),(2,b)}.$$ Because the pairs are ordered, $A \times B \neq B \times A$ in general, and $|A \times B| = |A|\cdot|B|$.

Set Operations

Given sets $A$ and $B$ inside a universal set $U$: the union $A \cup B = {x : x \in A \text{ or } x \in B}$; the intersection $A \cap B = {x : x \in A \text{ and } x \in B}$; the set difference $A - B = {x : x \in A \text{ and } x \notin B}$; and the complement $A' = U - A = {x : x \notin A}$. For $A = {10,11,12,13}$ and $B = {13,14,15}$: $A \cup B = {10,11,12,13,14,15}$ (the shared element $13$ is listed once), $A \cap B = {13}$, $A - B = {10,11,12}$ and $B - A = {14,15}$, showing that set difference is not commutative.

The symmetric difference of $A$ and $B$, written $A \oplus B$, is the set of elements in exactly one of $A$ or $B$: $$A \oplus B = (A - B) \cup (B - A) = (A \cup B) - (A \cap B).$$ It satisfies $A \oplus \emptyset = A$ and $A \oplus A = \emptyset$ for every set $A$, and it is commutative ($A \oplus B = B \oplus A$) and associative ($A \oplus (B \oplus C) = (A \oplus B) \oplus C$).

Union, intersection and complement satisfy the following identities, collectively the algebra of sets:

LawForm
Idempotent$A \cup A = A$, $\ A \cap A = A$
Associative$(A \cup B) \cup C = A \cup (B \cup C)$, $\ (A \cap B) \cap C = A \cap (B \cap C)$
Commutative$A \cup B = B \cup A$, $\ A \cap B = B \cap A$
Distributive$A \cup (B \cap C) = (A \cup B) \cap (A \cup C)$, $\ A \cap (B \cup C) = (A \cap B) \cup (A \cap C)$
De Morgan's$(A \cup B)' = A' \cap B'$, $\ (A \cap B)' = A' \cup B'$
Identity$A \cup \emptyset = A$, $\ A \cup U = U$, $\ A \cap U = A$, $\ A \cap \emptyset = \emptyset$
Complement$A \cup A' = U$, $\ A \cap A' = \emptyset$, $\ U' = \emptyset$, $\ \emptyset' = U$
Involution$(A')' = A$

Each of these can be proved directly from the definition of the operations. For instance, to prove the idempotent law $A \cup A = A$: since $B \subseteq A \cup B$ for any sets, taking $B = A$ gives $A \subseteq A \cup A$. Conversely, if $x \in A \cup A$ then $x \in A$ or $x \in A$, so $x \in A$ either way, giving $A \cup A \subseteq A$. The two inclusions together give $A \cup A = A$.

What this unit covers

  • Sets
  • Sets and Subsets
  • Power Set
  • Cartesian Product
  • Set Operations
  • Venn Diagram
  • Inclusion-Exclusion Principle
  • Computer Representation of Sets
  • Functions
  • Basic Concept
  • Injective and Bijective Functions
  • Inverse and Composite Functions
  • Graph of Functions
  • Functions for Computer Science (Ceiling Function, Floor Function, Boolean Function, Exponential Function)
  • Fuzzy Sets and Membership Functions
  • Fuzzy Set Operations
  • Sequences and Summations
  • Basic Concept of Sequences
  • Geometric and Arithmetic Progression
  • Single and Double Summation

Injective and Bijective Functions

2081 ยท 10 marks

Determine whether the function f(x) = x-1 from set of integers to the set of integers is injective, surjective or bijective. Write the type of Fuzzy set operations with their definition. Give the floor and ceiling value of 1.2 and -1.2.[10]

  • Function: $f(x) = x - 1$, with $f: \mathbb{Z} \to \mathbb{Z}$ (integers to integers) - Task 2: Types of fuzzy set operations with definitions - Values for floor/ceiling: $1.2$ and $-1.2$ --- Assume $f(x1) = f(x2)$: $$x1 - 1 = x2 - 1 \implies x1 = x2$$ Since equal images force equal inputs, $f$ ...
Open this answer on its own page โ†’

2079 ยท 10 marks

How do you plot the function on graph? Determine whether the function $f(x) = x^2$ is injective, surjective or bijective with reasons. Solve the recurrence relation $a_n = 6a_{n-1} + 9a_{n-2}$ with initial conditions $a_0 = 1, a_1 = 6$. [10]

  • Function: $f(x) = x^2$ (domain and codomain taken as $\mathbb{R} \to \mathbb{R}$) - Recurrence: $an = 6a{n-1} + 9a{n-2}$ - Initial conditions: $a0 = 1$, $a1 = 6$ --- Steps: 1. Choose several $x$-values from the domain. 2. Compute $f(x)$ for each to form ordered pairs $(x, f(x))$. 3. Draw the
Open this answer on its own page โ†’

Inclusion-Exclusion Principle

2080 ยท 5 marks

Explain the principle of inclusion and exclusion. How many integers from 1 to 30 are multiples of 2 or 3? [5]

Show solved answer

Principle of Inclusion and Exclusion

Given Data

  • Range of integers: 1 to 30
  • Divisibility conditions: multiples of 2 or multiples of 3

Statement of the Principle

The Principle of Inclusion and Exclusion is a counting technique for finding the number of elements in the union of finite sets. When we add the sizes of individual sets, elements common to more than one set get counted multiple times. The principle corrects this overcounting by systematically including individual set sizes, excluding pairwise intersections, including triple intersections, and so on.

For Two Sets:

$$n(A \cup B) = n(A) + n(B) - n(A \cap B)$$

For Three Sets:

$$n(A \cup B \cup C) = n(A) + n(B) + n(C) - n(A \cap B) - n(A \cap C) - n(B \cap C) + n(A \cap B \cap C)$$

The alternating signs (add odd-order intersections, subtract even-order... precisely: single sets +, pairs -, triples +) ensure each element is counted exactly once.


Application: Multiples of 2 or 3 from 1 to 30

Step 1: Define sets

  • $A$ = multiples of 2 in $[1,30]$
  • $B$ = multiples of 3 in $[1,30]$

We need $n(A \cup B)$.

Step 2: Multiples of 2 $$n(A) = \left\lfloor \frac{30}{2} \right\rfloor = 15$$

Step 3: Multiples of 3 $$n(B) = \left\lfloor \frac{30}{3} \right\rfloor = 10$$

Step 4: Multiples of both 2 and 3 (i.e. multiples of $\text{lcm}(2,3)=6$) $$n(A \cap B) = \left\lfloor \frac{30}{6} \right\rfloor = 5$$

Step 5: Apply the principle $$n(A \cup B) = n(A) + n(B) - n(A \cap B) = 15 + 10 - 5 = 20$$

$$\boxed{n(A \cup B) = 20}$$

Verification list: $${2,3,4,6,8,9,10,12,14,15,16,18,20,21,22,24,26,27,28,30}$$ Counting these gives exactly 20 integers. โœ“

Conclusion

There are 20 integers between 1 and 30 that are multiples of 2 or 3.

Open this answer on its own page โ†’

2076 ยท 5 marks

Define ceiling and floor function. Why do we need Inclusion - Exclusion principle? Make it clear with suitable example. [5]

Show solved answer

Floor and Ceiling Functions, and Inclusion-Exclusion Principle


1. Floor Function

The floor function for any real number x is defined as the greatest integer less than or equal to x.

It is denoted by โŒŠxโŒ‹.

Examples:

  • โŒŠ3.5โŒ‹ = 3
  • โŒŠ-2.4โŒ‹ = -3 (since -3 is the greatest integer less than or equal to -2.4)
  • โŒŠ3.143โŒ‹ = 3

2. Ceiling Function

The ceiling function for any real number x is defined as the smallest integer greater than or equal to x.

It is denoted by โŒˆxโŒ‰.

Examples:

  • โŒˆ3.5โŒ‰ = 4
  • โŒˆ-2.4โŒ‰ = -2 (since -2 is the smallest integer greater than or equal to -2.4)
  • โŒˆ3.143โŒ‰ = 4

3. Inclusion-Exclusion Principle

Why Do We Need It?

When counting elements in the union of two or more sets, simply adding the sizes of individual sets overcounts the elements that appear in more than one set. The Inclusion-Exclusion Principle corrects this overcounting by systematically including and excluding overlapping regions.

Without this principle, we would either overcount (by counting shared elements multiple times) or undercount (by ignoring them). It gives us an exact count of elements in the union of finite sets.


Statement

For any two finite sets A and B:

$$n(A \cup B) = n(A) + n(B) - n(A \cap B)$$

For three finite sets A, B, and C:

$$n(A \cup B \cup C) = n(A) + n(B) + n(C) - n(A \cap B) - n(A \cap C) - n(B \cap C) + n(A \cap B \cap C)$$

Here we include individual set sizes, exclude pairwise intersections, and include the triple intersection back.


Suitable Example

Problem: In a town of 10,000 families:

  • 40% buy newspaper A โ†’ n(A) = 4000
  • 20% buy newspaper B โ†’ n(B) = 2000
  • 10% buy newspaper C โ†’ n(C) = 1000
  • 5% buy A and B โ†’ n(A โˆฉ B) = 500
  • 3% buy B and C โ†’ n(B โˆฉ C) = 300
  • 4% buy A and C โ†’ n(A โˆฉ C) = 400
  • 2% buy all three โ†’ n(A โˆฉ B โˆฉ C) = 200

Find: Number of families that buy at least one newspaper.

Solution using Inclusion-Exclusion:

$$n(A \cup B \cup C) = n(A) + n(B) + n(C) - n(A \cap B) - n(A \cap C) - n(B \cap C) + n(A \cap B \cap C)$$

$$= 4000 + 2000 + 1000 - 500 - 400 - 300 + 200$$

$$= 7000 - 1200 + 200 = \mathbf{6000}$$

Number of families buying none of the newspapers:

$$= 10000 - 6000 = \mathbf{4000}$$


Conclusion

The Inclusion-Exclusion Principle is essential in combinatorics and set theory to accurately count elements in unions of overlapping sets, avoiding both overcounting and undercounting of shared elements.

Open this answer on its own page โ†’

Functions for Computer Science

2080 ยท 5 marks

Give the example of ceiling, floor and boolean function. How do you plot the graph of the function? [5]

The floor function for any real number x is defined as the greatest integer less than or equal to x. It is denoted by โŒŠxโŒ‹. Expression Value Reason --------- โŒŠ3.5โŒ‹ 3 Greatest integer โ‰ค 3.5 is 3 โŒŠ-2.4โŒ‹ -3 Greatest integer โ‰ค -2.4 is -3 โŒŠ3.143โŒ‹ 3 Greatest integer โ‰ค 3.143 is 3 --- The ceiling function...

Open this answer on its own page โ†’

Venn Diagram

2078 ยท 5 marks

Represent any three set operations using Venn-diagram. Give a recursive defined function to find the factorial of any given positive integer. [5]

--- The union of sets A and B contains all elements that belong to A or B (or both). A โˆช B = { x x โˆˆ A or x โˆˆ B } The entire shaded area of both circles represents A โˆช B. --- The intersection of sets A and B contains only the elements common to both A and B. A โˆฉ B = { x x โˆˆ A and x โˆˆ B } Only the...

Open this answer on its own page โ†’

Computer Representation of Sets

2075 ยท 10 marks

Consider a set U = {1,2,3,4,5,6,7,8,9,10}. What will be the computer representation for set containing the numbers which are multiple of 3 not exceeding 6? Describe injective, surjective and bijective function with examples.[10]

  • Universal set $U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}$ - Required set: numbers that are multiples of 3 not exceeding 6 --- Step 1 - Identify the required set Multiples of 3 that are $\leq 6$: - $3 \times 1 = 3$ โœ“ - $3 \times 2 = 6$ โœ“ - $3 \times 3 = 9$ (exceeds 6, excluded) So the required set i...
Open this answer on its own page โ†’

Basic Concept

2080.1 ยท 5 marks

Define function. Let $f_1$ and $f_2$ be function from $\mathbb{R}$ to $\mathbb{R}$ such that $f_1(x) = x^2$ and $f_2(x) = x - x^2$. What are the functions $f_1 + f_2$ and $f_1 \cdot f_2$? [5]

  • $f1, f2 : \mathbb{R} \to \mathbb{R}$ - $f1(x) = x^2$ - $f2(x) = x - x^2$ - Required: $f1 + f2$ and $f1 \cdot f2$ --- A function $f$ from a set $A$ to a set $B$ is an assignment that maps to each element $x \in A$ exactly one element $f(x) \in B$. Written as: $$f: A \rightarrow B$$ - $A$ is the ...
Open this answer on its own page โ†’

Fuzzy Sets and Membership Functions

2080.1 ยท 5 marks

Explain fuzzy set with example. How do you find complement of a fuzzy set? [5]

A fuzzy set is a set where each element has a degree of membership (also called membership value) that ranges between 0 and 1, rather than the classical (crisp) set where an element either belongs or does not belong to a set. In a classical set, membership is binary: 0 (not a member) or 1 (member...

Open this answer on its own page โ†’