






























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
BTEC Discrete Maths assignment 1
Typology: Papers
1 / 38
This page cannot be seen from the preview
Don't miss anything!
PROGRAM TITLE: BTEC in Computing
UNIT TITLE: Discrete Maths
ASSIGNMENT NAME: Set theory and functions- Graph theory
TUTORIAL LECTURER: Mrs. Luu Thi Huong Giang
STUDENT NAME: Nguyen Dac Trung Phuong
Summative Feedback:
I. Examine set theory and functions applicables to software engineering
1.1 Set theory
1.1.1 Set definition and basic concepts
Definition:
A set is a collection of distinct objects, called elements, where each element can be identified, and
there is no specific order.
Representation:
Sets are often represented using curly braces "{}". For example, the set of natural numbers less than
5 can be represented as {0,1,2,3,4}.
Elements:
The objects in a set are called the elements of the set.
Relationships between Sets:
Two sets can have relationships, such as being a subset (a set where all elements are also elements
of another set) or a union (a set containing all elements from other sets).
Empty Set:
A set with no elements is called an empty set, usually denoted as โ โ or {}.
Set Operations:
Various set operations, such as union, intersection, and complement, are used to perform logical
operations on sets.
1.1.2 Set operations
Union
Representation: AโชB
Meaning: Creates a new set containing all elements belonging to set A or set B, or both.
Intersection
Representation: AโฉB
1.1.5 Multiset
A multiset is a concept in set theory where each element can appear multiple times within the set.
Unlike a regular set, in a multiset, elements can be repeated.
Basic Characteristics of a Multiset:
Elements can appear multiple times
In a multiset, an element can appear multiple times, without any limitation on the number of
occurrences.
Used to model situations with repetitions
Multisets are often used to model real-world situations where the repeated occurrence of an object
is significant. For example, in a list of courses a student has registered for, the name of a course
may appear multiple times if the student enrols in the same course multiple times.
Representation
Multisets are commonly represented using square brackets or other symbols to indicate the number
of occurrences of each element.
Notation of Multiset and Cardinality
Multiset Notation:
A multiset is often represented using square brackets [ ] or curly braces { } to distinguish it from a
regular set. For example: [a,b,a,c,b] or {a,b,a,c,b} both serve as notations for a multiset.
Cardinality of Multiset:
The cardinality of a multiset is the count of occurrences for each element in the multiset. Typically,
it is denoted by indicating the frequency of each element, often in subscript form or another
context-appropriate manner. For instance, the cardinality of [a,b,a,c,b] can be expressed
as{a:2,b:2,c:1}.
Total Number of Elements:
At times, one might be interested in the total number of elements in the multiset. In the given
example, the total number of elements is 5.
1.2. Functions
1.2.1 Definition
A function is a mathematical relation between a set of inputs, known as the domain, and a set of
possible outputs, known as the codomain. The key characteristic of a function is that each input
value is uniquely associated with exactly one output value. In other words, a function assigns to
each element in the domain a specific element in the codomain.
Bijective : A function f: AโB is called bijective if it is both one-to-one and onto. This means that
each element in the set A is mapped to one and only one element in the set B, and every element in
the set B has at least one element in the set A mapped to it.
1.2.3 Inverse functions
In mathematics, an inverse function is a special function constructed to interchange the roles of the
range and domain of a given function. If f: AโB is a function, then the inverse function of f,
denoted as f
โ
, is defined as follows:
Domain and Range: The inverse function f
โ
: BโA has a domain that corresponds to the range of f,
and vice versa.
Mapping with the Original Function: For every x in B, f
โ
(x) is the unique value in A such that
when mapped through f, we obtain f (f
โ
(x)) = x.
Mapping with the Inverse Function: For every y in A, f (f
โ
(y)) = y.
One-to-One and Onto: If f is injective (one-to-one), then f
โ
is surjective (onto), and vice versa.
II. Graph theory
2.1 Definition
In mathematics, a graph is understood as a pair of two finite sets: the set of vertices and the set of
edges connecting these vertices to each other.
2.2 Types of graphs, how to classify and represent graphs on computers
2.2.1 Type of graphs
There are many of graphs:
Directed and Undirected graphs
An undirected graph is a graph where the edges do not have a specific direction and it is
bidirectional in nature it does not have a parent-child relation concept as there is no particular
direction.
Pseudograph : A graph that can have both multiple edges and loops.
Singleton Graph : A graph with only one vertex and no edges.
Empty Graph : A graph with no vertices and edges.
2.2.2 Classification methods
The classification of graphs in mathematics can be based on various criteria, depending on the
purpose of use and the characteristics of the data. Here are some primary ways to classify graphs:
Classification based on vertex and edge sets
Finite Graph : When both V (vertex set) and E (edge set) are finite sets.
Infinite Graph : When either V or E is an infinite set.
Classification based on edge properties
Undirected Graph : A graph where all edges are undirected.
Directed Graph : A graph in which all edges have a direction.
Mixed Graph : A graph that contains both undirected and directed edges.
2.2.3 Represent Graphs on a Computer
Adjency matrix
For the graph G = (V, E) with n vertices, the adjacency matrix of G is denoted as A = [a ij ]n x n,
where a ij
represents the number of edges connecting vertex i to vertex j.
For example:
2.3 Definition and Characteristics of Binary Trees
A binary tree is a data structure in computer science and mathematics. It consists of a set of nodes,
where each node can have at most two child nodes, called the left child and the right child. Each
node in the binary tree contains a value and is organized such that the value of the parent node is
greater than the value of the left child and less than the value of the right child.
Characteristics of Binary Trees:
Root Node:
The topmost node in the tree structure is called the root node. The root node has no parent.
Child Node:
Each node in the tree can have at most two child nodes, referred to as the left child and the right
child.
Leaf Node:
Nodes that do not have any child nodes are called leaf nodes. Leaf nodes are located at the last level
of the tree.
Depth:
The depth of a node is the number of nodes on the path from the root node to that node. The depth
of the root node is 0.
Full Binary Tree:
A full binary tree is a binary tree in which each node has exactly 0 or 2 child nodes.
Perfect Binary Tree:
A perfect binary tree is a full binary tree with all leaf nodes at the same level.
2.4 Definition of Spanning tree
A spanning tree is a subset of an undirected connected graph that includes all vertices with the
minimum possible number of edges. If any vertex is omitted, it is not considered a spanning tree. It
is a tree structure without cycles and ensures connectivity. A spanning tree comprises (n-1) edges,
where 'n' is the number of vertices. The edges may or may not have assigned weights. All possible
spanning trees derived from a graph G have the same number of vertices, but the number of edges is
equal to the number of vertices minus 1.
For a complete undirected graph with 'n' vertices, it can have (n^(n-2)) spanning trees. For example,
if n = 5, the maximum possible spanning trees would be 5 ^ (5-2) = 125.
Applications of spanning trees include cluster analysis, civil network planning, and computer
network routing protocols. In essence, spanning trees are employed to find the minimum path
connecting all nodes in a graph.
Characteristics of a Spanning Tree:
Connects All Vertices:
A spanning tree connects all the vertices of the original graph without forming cycles.
Objective: Find the shortest path from a source vertex to all other vertices in a graph with positive
edge weights.
Execution:
Create a set dist[] to store the shortest distances from the source vertex to all other vertices.
Initialize dist[] with infinity and set dist[source] to 0.
Iterate over all vertices:
Choose the vertex with the shortest distance from the source (not yet processed).
Update dist[] for all neighboring vertices if a shorter path is found.
Repeat the process until all vertices are processed.
Prim's Algorithm - Minimum Spanning Tree:
Objective: Find the minimum spanning tree of a weighted graph.
Execution:
Choose any vertex as the starting vertex of the minimum spanning tree.
Repeat the following steps until all vertices are included in the spanning tree:
Choose the edge with the minimum weight that connects a vertex in the spanning tree and a
vertex outside the spanning tree.
Add the selected vertex and edge to the spanning tree.
Repeat until the spanning tree contains all vertices.
III. Exercises
Part 1
1. Let A and B be two non-empty finite sets. If cardinalities of the sets A, B and A ๏ B are 86,
43 and 11 respectively, find the cardinality of the set A ๏ B?
n(A ๏ B) = n(A) + n(B) โ n(A ๏ B) = 86 + 43 - 11 = 118
=> n(A ๏ B ) = 118
2. Let A = {n ๏ N: 30 ๏ฃ n < 50} and B = {n ๏ N: 10 < n โค 42} and C = {n ๏ N: 5 < n ๏ฃ 35}
Suppose D is a set such that D ๏ A and D ๏ B and D ๏ C. What is the largest possible
cardinality of D?
Since A = {n โ N: 30 ๏ฃ n < 50} and D ๏ A, D = {n ๏ N: 30 ๏ฃ n < 50} (1)
Since B = {n ๏ N: 10 < n โค 42} and D ๏ B, D = {n ๏ N: 10 < n ๏ฃ 42} (2)
Since C = {n ๏ N: 5 < n ๏ฃ 35} and D ๏ C, D = {n ๏ N: 5 < n ๏ฃ 35} (3)
Combine statements (1), (2) and (3), we can conclude:
D = {n ๏ N: 30 ๏ฃ n ๏ฃ 35}
This is because 35 is the smallest upper limit and 30 is the largest lower limit among the three sets.
Therefore, the largest possible cardinality of D is 6
3. Let A = {1, 2, ..., 10}. Define B 2 = {B ๏ A: |B| = 2}. Find | B 2
|A| = 10, |B| = 2, so every element of B 2
is a pair of Aโs values.
2
10
2