You are on page 1of 14

PROGRAM TITLE: BTEC in Computing (Software Engineering)

UNIT TITLE: Discrete Maths

ASSIGNMENT NUMBER: Assignments 01

ASSIGNMENT NAME:

SUBMISSION DATE: 8/9/2022

DATE RECEIVED: 8/9/2022

TUTORIAL LECTURER: LUU THI HUONG GIANG

WORD COUNT:

STUDENT NAME: DUONG BA QUYEN

STUDENT ID: BKC12512

MOBILE NUMBER: 0377661895


Summative Feedback:
Internal verification:

Contents
A. INTRODUCTION..................................................................................................................3

LO1. EXAMINE SET THEORY AND FUNCTIONS APPLICABLE TO SOFTWARE


ENGINEERING............................................................................................................................4

I. SET THEORY..............................................................................................................................................4
II. FUNCTION................................................................................................................................................4
III. MULTISET................................................................................................................................................4
IV. PART 1......................................................................................................................................................5
V. PART 2......................................................................................................................................................5
VI. PART 3......................................................................................................................................................6
VII. PART 4......................................................................................................................................................7

LO2: ANALYSE MATHEMATICAL STRUCTURES OF OBJECTS USING GRAPH


THEORY........................................................................................................................................8

I. INTRODUCTION GRAPH THEORY...............................................................................................................8


III. PART 6....................................................................................................................................................11
IV. PART 7....................................................................................................................................................11
V. PART 8....................................................................................................................................................12

B. REFERENCES.....................................................................................................................14
A. Introduction.

LO1. Examine set theory and functions applicable to software engineering.

I. Set Theory

1.

II. Function.

1. Introduction to Function
- A function is a rule that assigns each input exactly one output. We call the output the
image of the input. The set of all inputs for a function is called the domain. The set of all
allowable outputs is called the codomain.
- We would write f: X → Y to describe a function with name f, domain X and codomain Y
- To define the function, we must describe the rule. This is often done by giving a formula
to compute the output for any input (although this is certainly not the only way to
describe the rule)

III. Multiset

1. Introduction to Multiset
- A multiset (mset, for short) is an unordered collection of objects (called the elements) in
which, unlike a standard (Cantorian) set, elements are allowed to repeat. In other words,
an mset is a set to which elements may belong more than once, and hence it is a non-
Cantorian set.
- The number of distinct elements in an mset M (which need not be finite) and their
multiplicities jointly determine its cardinality, denoted by C(M). In other words, the
cardinality of an mset is the sum of multiplicities of all its elements.
2. Basic of Multiset.
 Representations of Multisets
 Multiplicative form
- Following Meyer and McRobbie, the use of square brackets to represent an mset has
become almost standard. Thus, an mset containing one occurrence of a, two occurrences
of b, and three occurrences of c is notation ally written as [[a, b, b, c, c, c]] or [a, b, b, c,
c, c] or[a , b , c ]1,2,3 or [a 1,b 1,c 1 ] or [a1, b2, c3], depending on one’s taste and convenience.

IV. Part 1

1. Let A and B be two non-empty finite sets. If cardinalities of the sets A, B, and A ∩ B
are 80, 52 and 17 respectively, find the cardinality of the set A ∪ B.
2. Let A = {n∈N:30≤n<50} and B = {n∈N:10<n≤42}. Suppose C is a set such that C⊆A
and C⊆B. What is the largest possible cardinality of C?
3. Let A = {1, 2,…,10}. Define B2 = {B⊆A:|B| = 2}. Find | B2|?
4. Consider the sets A and B, where A = {3, |B|} and B = {1, |A|, |B|}. What are the
sets?

The answer:

1. We have: |A| = 80, |B| = 52, |A ∩ B| = 17


Applying formula: |A ∩ B| = |A| + |B| - |A ∪ B|
 17 = 80 + 53 - |A ∪ B|

 |A ∪ B| = 80 + 53 -17

|A ∪ B| = 115

2. Đ
3. a
4. Consider the sets A and B, where A = {3, |B|} and B = {1, |A|, |B|}.
Let us prove by contradiction that ∣B∣ = 3.
Suppose that |B| = 3.
Then cardinality of the set A = {3, 3} = {3} is equal to 1, and hence the set B = {1, |A|, |
B|} = {1, 1, 3} = {1, 3} has cardinality 2.
And we have a contradiction with |B| = 3.
Therefore, ∣B∣ = 3, and hence |B| < 3.
It follows that |A | = 2.
Then B = {1, ∣A∣, ∣B∣} = {1, 2, ∣B∣}, and hence ∣B∣ = 2.
We conclude that A = {3, 2} and B = {1, 2}.
V. Part 2

1. Write the multi-sets of prime factors of given numbers.


a. 750
b. 3250
2. Find the cardinalities of each multiset in part 2-1.
3. Present the application of set and multiset in software engineering? Give specific
programming example

The answer:

1. a. 750 = 21 × 53 × 31
Multiset of 750 of prime factors = {2, 5, 5, 5, 3}
b. 3250 = 21 × 53 × 131
Multiset of 3250 of prime factors = {2, 5, 5, 5, 13}
2. a = {2, 5, 5, 5, 3}, |a |= 5
b = {2, 5, 5, 5, 13}, |b| = 5
3. Code

VI. Part 3

The answer:

1.

a.

b.

2. Let f(x) = y
Therefore

5
y = (x - 32)
9

⟹ 9y = 5x - 160

⟹ 9y + 160 = 5x

1 9
⟹ x = (9y + 160) = y + 32
5 5

9
Therefore the opposite function, which convert Celsius to Fahrenheit is y+32, where y is the
5
temperature in Celsius: i, e,

9
=> x °C, ( y+32)°F
5

3. Code

VII. Part 4

1. Formulate corresponding proof principles to prove the following properties about defined
sets.
A = B  A ⊆ B and B ⊆ A
2. De Morgan's Law by mathematical induction.
3. Distributive Laws for three non-empty finite sets A, B, and C.

The answer:

1. Suppose we want to show A = B. If we show A ⊆ B, then every element of A is also in B, but


there is still a possibility that B could have some elements that are not in A, so we cannot
conclude A = B. But if in addition we also show B ⊆ A, then B cannot contain anything that is
not in A, so A = B

2. Prove De Morgan’s Law

#1 Complement of the Union Equals the Intersection of the Complements

Let P = (A U B)' and Q = A' ∩ B' Let x be an arbitrary element of P then x ∈ P ⇒ x ∈ (A U B)'
⇒ x ∉ (A U B) ⇒ x ∉ A and x ∉ B ⇒ x ∈ A' and x ∈ B' ⇒ x ∈ A' ∩ B' ⇒ x ∈ Q

Prove De Morgan’s Law


#2 Complement of the Intersection Equals the Union of the Complements Let P = (A ∩ B)' and
Q = A' U B' Let x be an arbitrary element of P then x ∈ P ⇒ x ∈ (A ∩ B)' ⇒ x ∉ (A ∩ B) ⇒ x ∉
A or x ∉ B ⇒ x ∈ A' or x ∈ B' ⇒ x ∈ A' U B' ⇒ x ∈ Q

3. Using the Indirect Method

Let A, B, C besets. If A⊆B and B ∩ C = ∅, then A∩C=∅

If we assume the conclusion is false and we obtain a contradiction

=> Then the theorem must be true.

Assume A ⊆ B and B ∩ C = ∅, and A ∩ C ≠ ∅.

To prove that this cannot occur, let x ∈ A∩C.

x ∈ A ∩ C ⇒ x ∈ A and x ∈ C ⇒ x ∈ B and x ∈ C ⇒ x ∈ B ∩ C

But this contradicts the second premise. Hence, the theorem is proven.

LO2: Analyse mathematical structures of objects using graph theory.

I. Introduction Graph Theory

A. Graph definition
- Definition: A graph is understood as a set of two finite sets: the set of vertices and the set
of edges connecting these vertices.
- Notation: the graph is G (Graph), the vertex set is V (vertex), and the edge set is E (edge).
B. Undirected Graph
- Undirected graph G = (V, E) where:
- V is the set of elements called vertices
- E is the set, each element is an unordered pair (u, v) of two vertices in V.
- (u, v) is called the edge connecting vertex u and vertex v.
- We have (u, v) ≡ (v, u)
C. Directed graphs
- Definition: Directed graph, denoted G = [V, E] where:
- V is the set of elements called vertices
- E is the set, each element is an ordered pair [u, v] of two vertices of the set V
- [u, v] is called the arc connecting u to v.
- Note: [u, v] ≠ [v, u]
D. Graph classification
 Classification by vertices and edges
- Finite Graph: When both V and E are finite sets
- Infinite Graph: When V or E is an infinite set
 Classification according to edge properties
- Undirected Graph: a graph with all edges being undirected
- Directed Graph: A graph whose edges are all directed
- Mixed Graph: A graph with both undirected and directed edges
 In addition, we also have the following types of graphs:
- Simple graph: is a graph that does not contain rings and double edges
- Multigraph: is a graph containing double edges and no rings
- Pseudo graph: is a graph that contains both double and ring edges
- Point graph: is a graph with only one point and no edges
- Empty graph: is a graph that has no vertices and edges.
E. Eulerian circuit
- Concept: Given an undirected graph G = (V, E) has n vertices, and m edges. An Euler
line in G is a sequence containing all m edges of the graph and has the form: P1, e 1, P2, e 2
, ..., Pm, e m, Pm +1 such that edge e i is the edge connecting two vertices Pi and Pi+1 .
- If P1= Pm +1, we call it a closed Euler line
- If P1 ≠ Pm +1, we call it an open Euler line
 Theorem 1: An undirected and connected graph G = (V, E) has a closed Euler line 
degree of all vertices in G is even.
 Theorem 2: The necessary and sufficient condition for a connected graph G to have an
open Euler line is that the number of vertices of odd degree in the graph is 2.
F. Hamilton cycle
- Concept: Let the graph G = (V, E). A cycle C is called a Hamiltonian cycle if it passes
through all the vertices of the graph.
- If there exists a path H with such properties, then H is called a Hamilton path.
G. Dijkstra's algorithm
- Find the shortest path from vertex a to z of a connected weighted graph G = (V, E)
- Let L (v) be the length of the shortest path from vertex a to vertex v.
- S is the set of vertices that have found the shortest path from a to it.
 Dijkstra's algorithm:
 Step 1: L(a) = 0, S = Ø, ∀ v ∈ V, v ≠a: L(v) = ∞
 Step 2: If z ∈ S then finish.
 Step 3: Choose v ∉S such that L (v) is the smallest. Put v into S.
 Step 4: For each adjacent vertex x v and x ∉ S, set: L(x) = min{L(x), L(v) + c(v, x)} Go
back to step 2.
H. S
I. d

II. Part 5

1. Discuss using two examples on binary trees both quantitatively and qualitatively.

The answer:

BINARY TREE: Each node can have at most two children. Maximum number of nodes possible
at any level i is2i. Binary tree play a vital role in a software application.one of the most
application of binary

Tree is searching algorithm.

Binary tree is a special data structure used for data storage purpose. Binary tree are used to
represent a nonlinear data structure.

First example Quantitative binary tree

Complete binary tree: A binary tree is a complete binary tree if all levels are filled (except the
last level and the last level has nodes as left as possible).

Maximum nodes = 2h+ 1 -1

Minimum nodes = 2h

Maximum height = log n

Second Example Qualitative binary tree

FULL BINARY TREE: Each node has either 0 or 2 children. Each node will contain exactly two
children

Except leaf node

Number of leaf nodes = number of internal node +1

Maximum nodes = 2h+ 1- 1

Minimum nodes = 2h + 1
Maximum height = (n-1)/2

Array especially suited for full binary tree

III. Part 6

1. State the Dijkstra's algorithm for a directed weighted graph with all non-negative edge
weights.
2. Find the shortest path spanning tree for the weighted directed graph with vertices A, B,
C, D, and E given using Dijkstra's algorithm.

The answer:

1. Dijkstra's algorithm solves the shortest path problem for a directed weighted graph with
non-negative weights. As the weights are non-negative, consequently, it is assumed that
w (e) ≥ 0 for all e ∈ E.
- The algorithm maintains a priority queue minQ that is used to store the unprocessed
vertices with their shortest-path estimates est(v) as key values. It then repeatedly extracts
the vertex u which has the minimum est(u) from minQ and relaxes all edges incident
from u to any vertex in minQ. After one vertex is extracted from minQ and all relaxations
through it are completed, the algorithm treats this vertex as processed and does not
consider it again. The algorithm stops either when the priority queue (minQ) is empty or
when every vertex is examined exactly once.
2.

IV. Part 7

Check whether the following graphs have an Eulerian and/or Hamiltonian circuit.
V. Part 8

1. Construct a proof for the five color theorem for every planar graph.
2. Discuss how efficiently Graph Theory can be used in a route planning project for a
vacation trip from 17 Ta Quang Buu (Ha Noi) to Ha Long Bay (Quang Ninh) by
considering most of the practical situations (such as millage of the vehicle, etc.) as much
as you can. Essentially consider the twofold:
 Routes with shortest distance(Quick route travelling by own vehicle)
 Route with the lowest cost
3. Radio stations broadcast their signal at certain frequencies. However, there are a limited
number of frequencies to choose from, so nationwide many stations use the same
frequency. This works because the stations are far enough apart that their signals will not
interfere; no one radio could pick them up at the same time. Suppose 10 new radio
stations are to be set up in a currently unpopulated (by radio stations) region. The radio
stations that are close enough to each other to cause interference are recorded in the table
below. What is the fewest number of frequencies the stations could use?
The answer:

1. Theorem: Every planar graph with n vertices can be colored using at most 5 colors.

Proof by induction, we induct on n, the number of vertices in a planar graph G.

Base case, P (n≤5): Since there exist ≤5 nodes in G, the graph can be colored using 5 colors.

Inductive step, P (n+1): Assuming P (n)

P (n) is true, that is, every planar graph with n vertices, we need to show P (n)

P (n) is true.

We know every planar graph has one vertex with deg (v) ≤ 5. We call this vertex v in our graph
G. Remove v and for the remaining subgraph G′ we can assume P (n).

If deg (v) ≤ 4, we can color all vertices adjacent to v using 4 colors and use color 5 to color v
itself to reach a valid coloring.

If deg (v) = 5, we assume that all vertices adjacent to v are colored in distinct colors.

Hence proved.

2. s
B. References.

You might also like