Docsity

Discrete Mathematics: Exploring Sets, Prime Factorization, Binary Trees, and Graph Theory, Schemes and Mind Maps of Law

Toggle sidebar
bg1
ASSIGNMENT 1 FRONT SHEET
Qualification Pearson BTEC Level 5 Higher National Diploma in Computing
Unit number and title Unit 18: Discrete Maths
Submission date 8-7-2024 Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Chu Duc Anh Student ID BH01254
Class SE06206 Assessor name Ta Quang Hieu
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature Anhhhh
Grading grid
P1 P2 P3 P4 M1 M2 D1 D2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Discrete Mathematics: Exploring Sets, Prime Factorization, Binary Trees, and Graph Theory and more Schemes and Mind Maps Law in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification Pearson BTEC Level 5 Higher National Diploma in Computing

Unit number and title Unit 18: Discrete Maths

Submission date 8-7- 2024 Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Chu Duc Anh Student ID BH

Class SE06206 Assessor name Ta Quang Hieu

Student declaration

I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that

making a false declaration is a form of malpractice.

Student’s signature Anhhhh

Grading grid

P1 P2 P3 P4 M1 M2 D1 D

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date:

Internal Verifier’s Comments:

Signature & Date:

1.Let A and B be two non-empty finite sets. Assume that cardinalities of the sets A,B and A ⋂ B are

9𝑏, 2𝑎 and a + b, respectively. Determine the cardinality of the set A ⋃ B.

Solution:

|A| = 95 , |B|=

|A ⋂ B| = 9

|A ⋃ B| = |A| + |B| - |A ⋂ B| = 110

  1. Suppose |A – B| = 3𝑎 ,|A ⋃ B| =11𝑏 and |A ⋂ B| = 1𝑎. Determine |B|

Solution:

|A – B| = 34

|A ⋃ B| = 115

|A ⋂ B| = 14.

|A ⋃ B| = |A| + |B| - |A ⋂ B|

115 = (|A – B| + |A ⋂ B|) + |B| - |A ⋂ B|

115 = (34 + 14) + |B| - 14

115 = 48 + |B| - 14

|B| = 81

3.At a local market, there are 35𝑏 customers. Suppose 11𝑎 have purchased fruits,9𝑏 have

purchased vegetables, 8𝑎 have purchased bakery items, 4𝑏 have purchased both fruits and

vegetables, 3𝑏 have purchased both vegetables and bakery items, 2𝑎 have purchased both fruits

and bakery items, and 1𝑎 have purchased all three categories. How many customers have not

purchased anything?

Number of customers at the market: |U| = 355

Number of customers buying fruit: |A| = 114

Number of customers buying vegetables: |B| = 95

Number of customers buying bread: |C| = 84

Number of customers buying fruits and vegetables: |A ∩ B| = 45

Number of customers buying vegetables and bread: |B ∩ C| = 35

Number of customers buying fruit and bread: |A ∩ C|= 24

Number of customers buying all 3 types mentioned above: |A ∩ B ∩ C | = 14

Solution:

𝐴 ∪ 𝐵 ∪ C

= |A| + |B| + |C| - |A ∩ B| - |B ∩ C| - |A ∩ C| + |A ∩ B ∩ C |

|A ⋃ B ⋃ C| = 114 + 95 + 84 – 45 – 24 – 35 + 14

|A ⋃ B ⋃ C| = 203

Number of customers who did not buy anything:

= |U| -

𝐴 ∪ 𝐵 ∪ C

Part II. Keep in mind that represents the largest digits in your ID.

  1. List the bag of prime factors for each of the provided numbers.

a)

Solution: 142 = 2 × 71

A= {|2:1,71:1 |}.

b)

Solution: 250 = 2 x 5 x 5 x 5

B = {|2:1,5:3|}

  1. Find the cardinalities of

a) each of the aforementioned bags.

Difference (142 - 250): {∣ 2 : max(1 , 1), 7 1 : max(1 , 0)} = {∣ 71 : 1|}

For 5: Do not appear in the bag for 142, so they are not included in the difference

 Element 2 appears max(1 , 1) = 0 times

 Element 71 appears max(1 , 0) = 1 times

=> The cardinality of the difference is {71}

Part III. Bear in mind that 𝒂 < 𝒃 represents the largest digits in your ID.

a. Ascertain whether the given functions are invertible. If they are, identify the rule for the inverse

function f

a) 𝑓: ℝ → ℝ 𝑤𝑖𝑡ℎ 𝑓

I have 𝑓: ℝ → ℝ 𝑤𝑖𝑡ℎ 𝑓

A function is injective if different inputs produce different outputs. Let's check:

1

2

1

2

1

2

1

2

So, f is injective.

A function is surjective if every element in the codomain is mapped by some element in the domain. For

any 𝑦 ∈ ℝ , we need to find an 𝑥 ∈ ℝ such that 𝑓

x=

( y − 4 )

=> f(x)=

5 ( y − 4 )

=y

The function f is a onto.

Given y=bx+ a solve for x:

Thus, the inverse function f

(y) is:

−

(y - 4)

b)

𝑓: [−𝑏, +∞) → [0, +∞) 𝑤𝑖𝑡ℎ 𝑓(𝑥) =

To determine if f is invertible, we need to check if it is a bijection (both injective and surjective)

Injectivity: Assume x

1

, x

2

∈ [– 5, + ∞ )

From (1) , (2) ⇒

3

Part IV. Show that if , A B and C are sets , then

A ∪ B ∪C = A ∩ B ∩C

b. Demonstrate that each side is a subset of the other side. Show that

A ∪ B ∪C = A ∩ B ∩C

A ∪ B ∪C

A ∩ B∩ C

 A ∩ B∩ C

A ∪ B ∪C

If

x ∈ A ∪ B ∪C , then x ∉ A ∪ B ∪ C that mean x ∉ A, x ∉ B and x ∉ C

 x

∈ A

, x

∈ b ,x

∈ C

=> x

∈ A ∩ B∩ C

 A ∪ B ∪C ⊆ A ∩ B∩ C

If

x ∈ A ∩ B∩ C , then x

∈ A

, x

∈ b ,x

∈ C

=> x ∉ A, x ∉ B and x ∉ C

 x∉

A ∪ B ∪C

x ∈ A ∪ B ∪CA ∩ B∩ C ⊆ A ∪ B ∪C

c. Verify the equality using a membership table.

d. Verify the equality using a membership table.

Make a truth table in order to confirm the equality.

A

B

C

A ∪ B ∪

C

A ∪ B ∪C A 𝐵 𝐶 A ∩ B ∩

C

The membership table is used to confirm the equivalence because the columns

A ∪ B ∪C

and

A ∩ B∩ C have the same values for every conceivable combination of A, B, and C

II.Activity 2.

Part I. Discuss two notable instances of binary trees, providing both quantitative and

qualitative analyses.

1. Binary Tree Data Structure:

A binary tree is a hierarchical data structure commonly used in computer science to organize and

manage data effectively. It consists of nodes, each of which can have up to two children, known as the

left child and the right child. This structure enables efficient searching, sorting, and manipulation of data.

 The level of a node is defined as its depth in the tree, with the root node considered to be at level

 The depth of a node indicates the distance from the root to that particular node, measured

by the number of edges traversed along the path.

Height:

 The height of a binary tree is the length of the longest path from the root to a leaf node.

 It represents the maximum number of levels or layers in the tree, providing insights into

the overall structure and complexity of the tree.

 The height of a binary tree influences its performance and efficiency in terms of traversal,

insertion, and deletion operations.

Applications:

Binary trees have widespread applications in various domains of computer science and software

engineering, including:

Searching: Binary search trees leverage the binary tree structure to perform efficient

search operations with logarithmic time complexity.

Sorting: Binary trees can be utilized for sorting elements in logarithmic time through techniques

such as heap sort and balanced binary search trees.

Expression Parsing: Binary expression trees are employed for parsing and evaluating

mathematical expressions, providing a structured representation of arithmetic operations.

Hierarchical Representation of Data: Binary trees serve as a foundational structure for

representing hierarchical data sets, including file systems, organization charts, and XML

parsing algorithms.

2. Types of binary tree:

a) Full Binary Tree.

Definition of a Full Binary Tree:

A full binary tree is a specific type of binary tree in which every node has either zero or two children. In

other words, each node in a full binary tree is either a leaf node (having no children) or an internal node

(having exactly two children).

Figure 2:Full binary tree

Characteristics of a Full Binary Tree:

  1. Node Structure:

o Every node has either 0 or 2 children.

o There are no nodes with only one child.

  1. Height and Nodes Relationship:

o For a full binary tree of height h, the total number of nodes N is given by the formula:

N=

h+

o This indicates an exponential growth in the number of nodes with respect to the height

of the tree.

  1. Leaf Nodes and Internal Nodes:

o The number of leaf nodes LLL in a full binary tree is L=(N+1)/

o The number of internal nodes (nodes with two children) is I=(N−1)/

Properties of a Full Binary Tree:

  1. Balanced Structure:

o A full binary tree is more balanced compared to other types of binary trees, as every

level except possibly the last is completely filled.

  1. Traversal Efficiency:

o Traversal operations like in-order, pre-order, and post-order are efficient due to the

balanced nature of the tree.

  1. Application Suitability:

o Full binary trees are particularly useful in applications where a balanced structure is

crucial, such as in certain types of heap implementations and in some search

algorithms.

Examples:

  1. Full Binary Tree of Height 2:

o Height h=

o Number of nodes N=

2+

o Nodes at the last level are filled from left to right without any gaps.

  1. Height and Nodes Relationship:

o For a complete binary tree of height h the number of nodes N can range between 2

h

and

h+

  1. Balanced Nature:

o While not perfectly balanced like a full binary tree, a complete binary tree ensures a

high degree of balance, minimizing the tree's height and ensuring efficient operations.

Properties of a Complete Binary Tree:

  1. Node Indexing:

o Nodes can be indexed in a level-order manner, which simplifies the implementation of

binary heaps.

o For a node at index iii:

 Its left child is at index 2i+

 Its right child is at index 2i+

 Its parent is at index [(i−1)/2]

  1. Efficiency in Operations:

o Operations such as insertion, deletion, and searching are efficient, typically having a time

complexity of O(log n) due to the balanced nature of the tree.

  1. Memory Utilization:

o The compact structure of complete binary trees ensures efficient memory utilization,

making them suitable for array representations.

Examples:

  1. Complete Binary Tree of Height 2:

o Height h=

o Number of nodes N ranges from 2

2

=4 to 2

2+

o The tree could have all levels fully filled or the last level partially filled from left to right.

  1. Complete Binary Tree of Height 3:

o Height h=

o Number of nodes N ranges from 2

3

=8 to 2

3+

o The tree could have all levels fully filled or the last level partially filled from left to right.

Applications of Complete Binary Trees:

  1. Binary Heaps:

o Complete binary trees are the underlying structure for binary heaps (both min-heaps and

max-heaps), used in priority queue implementations.

  1. Breadth-First Search (BFS):

o The structure of complete binary trees makes them ideal for BFS operations, where

nodes are processed level by level.

  1. Efficient Storage:

o Due to their compact nature, complete binary trees are often stored using arrays,

allowing for efficient indexing and minimal wasted space.

  1. Data Structures and Algorithms:

o Complete binary trees are used in various algorithms and data structures that require

balanced and efficient access patterns, such as segment trees and binary indexed trees.

Part II. Stick in mind that a < b represents the largest digits in your ID.

My ID:BH

I have a = 1 , b = 6

1. State Dijkstra’s Algorithm in an undirected graph.

Dijkstra's algorithm can solve the problem of finding the shortest path on both undirected and directed

graphs as long as the weights are not negative.. Let G be a weighted graph. To find the shortest path

between a and z in G, we use the

Dijkstra’s algorithm as the following

Finds the length of the shortest path from a to the first vertex.

Finds the length of the shortest path from a to the second vertex.

Finds the length of the shortest path from a to the third vertex.

Continue the process until z is reached.

  1. Apply Dijkstra’s algorithm to determine the shortest path length between vertices Aand Z in the

provided weighted graph.

Accordingly, B is the first vertex closest to A and the shortest path from A to b has length 1.

Now, we need to find the second closest vertex to a by examining all paths that begin with the shortest

path from the vertex b (Note that this shortest path contains A and B).

Figure 5:Step 1

Here, B is the second closest vertex to C, and the shortest path from A to B is A,C, with length 4.

But we will not consider this vertex because the distance from A to D that passes through vertex B, A,C,B,

has a length of 7 greater than the distance from A to D that passes through vertex C with distance A, C

has a length of 4.

To determine the third closest vertex to A, we need to checking all paths that begin with shortest path

from the vertex D (Note that this shortest path contains A,C,D).