báo cáo cuối kỳ môn cấu trúc rời rạc

32 21 0
Tài liệu đã được kiểm tra trùng lặp
báo cáo cuối kỳ môn cấu trúc rời rạc

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

BÁO CÁO CUỐI KỲMÔN CẤU TRÚC RỜI RẠCNgười hướng dẫn: TS NGUYỄN THỊ HUỲNH TRÂMNgười thực hiện: NGUYỄN VÕ CÔNG HUYLớp : 20050301Khoá : 24THÀNH PHỐ HỒ CHÍ MINH, NĂM 2021... BÁO CÁO CUỐI KỲMÔ

Trang 1

BÁO CÁO CUỐI KỲ

MÔN CẤU TRÚC RỜI RẠC

Người hướng dẫn: TS NGUYỄN THỊ HUỲNH TRÂMNgười thực hiện: NGUYỄN VÕ CÔNG HUY

Lớp : 20050301Khoá : 24

THÀNH PHỐ HỒ CHÍ MINH, NĂM 2021

Trang 2

BÁO CÁO CUỐI KỲ

MÔN CẤU TRÚC RỜI RẠC

Người hướng dẫn: TS NGUYỄN THỊ HUỲNH TRÂMNgười thực hiện: NGUYỄN VÕ CÔNG HUY

Lớp : 20050301Khoá : 24

THÀNH PHỐ HỒ CHÍ MINH, NĂM 2021

Trang 3

LỜI CẢM ƠN

Em xin chân thành cảm ơn đến cô Nguyễn Thị Huỳnh Trâm, và đội ngũ giảngviên trường đại học Tôn Đức Thắng đã tận tình giảng dạy trong suốt đại dịch giúp emhoàn thành bài cáo này.

Trang 4

CÔNG TRÌNH ĐƯỢC HOÀN THÀNHTẠI TRƯỜNG ĐẠI HỌC TÔN ĐỨC THẮNG

Tôi xin cam đoan đây là công trình nghiên cứu của riêng tôi và được sự hướngdẫn khoa học của TS Nguyễn Thị Huỳnh Trâm; Các nội dung nghiên cứu, kết quảtrong đề tài này là trung thực và chưa công bố dưới bất kỳ hình thức nào trước đây.Những số liệu trong các bảng biểu phục vụ cho việc phân tích, nhận xét, đánh giá đượcchính tác giả thu thập từ các nguồn khác nhau có ghi rõ trong phần tài liệu tham khảo.

Ngoài ra, trong luận văn còn sử dụng một số nhận xét, đánh giá cũng như số liệucủa các tác giả khác, cơ quan tổ chức khác đều có trích dẫn và chú thích nguồn gốc.

Nếu phát hiện có bất kỳ sự gian lận nào tôi xin hoàn toàn chịu trách nhiệmvề nội dung luận văn của mình Trường đại học Tôn Đức Thắng không liên quan đếnnhững vi phạm tác quyền, bản quyền do tôi gây ra trong quá trình thực hiện (nếu có).

TP Hồ Chí Minh, ngày 25 tháng 12 năm 2021 Tác giả

Nguyễn Võ Công Huy

Trang 5

TÓM TẮT

Bài báo cáo bao gồm các nội dung cốt lõi, chung nhất của môn Cấu Trúc RờiRạc, giúp nắm vững nền móng các hướng tư duy thuần cơ bản nhằm giúp sinh viên ghinhớ và hiểu sâu hơn về bộ môn này.

Trang 6

Question 1 – Euclid’s algorithm and Bezout’s identity 4

Question 2 – Recurrence relation 5

Question 3 – Set 7

Question 4 – Relations 8

Question 5 – Multiplicative inversion 9

Question 6 – Kruskal’s algorithm 11

Question 7 – Eulerian circuit 15

Question 8 – Map coloring 18

TÀI LIỆU THAM KHẢO 25

PHỤ LỤC 26

Trang 7

DANH MỤC KÍ HIỆU VÀ CHỮ VIẾT TẮT

CÁC KÝ HIỆU

CÁC CHỮ VIẾT TẮT

Trang 8

DANH MỤC CÁC BẢNG BIỂU, HÌNH VẼ, ĐỒ THỊDANH MỤC HÌNH

DANH MỤC BẢNG

Trang 9

Question 1: Euclid’s algorithm and Bezout’s identity

a Using Euclid’s algorithm to calculate gcd(2021, 1000 + m) and lcm(2021, 1000 +m), where m is the last 3 digits of your student ID

SolveStudent ID : 52000765 m = 765

Let’s trace Euclid’s algorithm to calculate gcd(2021;1765) gcd(2021;1765)

2021 = 1765*1 + 256 gcd(1765;256)1765 = 256*6 + 229 gcd(256;229) 256 = 229*1 + 27 gcd(229;27) 229 = 27*8 + 13 gcd(27;13) 27 = 13*2 + 1 gcd(13;1) 13 = 1*13 + 0 gcd(1;0)Thus gcd(2021;1765) = 1gcd(a;b) * lcm(a;b) = a * b

lcm(a;b) = = = = 3567065

b Apply above result(s) in to find 5 integer solution pairs (x,y) of this equation: 2021x + (1000 + m)y = gcd(2021; 1000 + m)

SolveStudent ID : 52000765 m = 765

Equation : 2021x + 1765y = gcd(2021; 1765)1 = 27 – 13*2 = 27 + 13*(–2)

Trang 10

= 27 + (229 – 27*8)*(–2) = 229*(–2) + 27*17 = 229*(–2) + (256 – 229)*17

= 229*(–19) + 256*17 = (1765 – 256*6)*(-19) + (2021 – 1765)*17 = [1765 – (2021 – 1765)*6]*( –19) + (2021 – 1765)*17

= [2021*(–6) + 1765*7]*( –19) + (2021 – 1765)*17 = 2021*131 + 1765*(–150)

Thus 1 = 2021*131 + 1765*(–150)Due to the form of equation: ax + by = d, so

Once a solution pair (x, y) is found, additional pairs may be generated by , where k is any integer.

Proof steck:

1 = 2021*131 + 1765*(–150)

k = 1 => = (1896; –2171)k = 19 => = (35431; –40570)k = 11 => = (54846; –62801)k = 2 => = (58376; –66843)k = 2002 => = (3591906; –4112885)

Question 2: Recurrence relation

Solve the recurrence relation

an = 8a – 15an−1n−2

with a0 = 5 and a1 = m, where m is the last 2 digits of your student ID.Solve

Student ID : 520007 m = 65 65

Trang 11

Suppose a sequence a , a , a ,… satisfies the recurrence relation012

an = 8a – 15an−1n−2 for every integer n 2,with initial conditions

a0 = 5 and a = m = 65.1

This sequence sitisfies part of the hypothesis of the single-root theorem becauseit satisfies a second-order linear homogeneous recurrence relation with constantcoefficients(A = 8 and B = –15) To check that it satisfies the second part of thehypothesis, examine the characteristic equation.

t2 – 8t + 15 = 0

By the quadratic formula t = 5, t = 3 [since t2 – 8t + 15 = (t – 5)*(t – 3)] and so theroots are distinct Thus it follows from the distinct-roots theorem that the sequence isgiven by the explicit formula.

an = C*5 + D*3nn for each integer n 0

Where C and D are the numbers whose values are determined by the fact that a = 5; 0

a1 = 65 To find C and D, write a = 5 = C + D and a = 65 = 5*C + 3*D01

Now substitute C = 25 and D = 20 into formula to conclude that –an = 52 + n – 20*3n for each integer n 0

Question 3: Set

a Create a set Γ of characters from your case-insensitive non-diacritical full name For example, the set corresponding with “Tôn Đức Thắng” is Δ = {A, C, D, G, H, N, O, T, U}

SolveMy full name: “Nguyễn Võ Công Huy”

Trang 12

Γ = {C, E, G, H, N, O, U, V, Y}

b Find the union, intersect, non-symmetric difference, and symmetric difference of Γ and Δ, where Γ and Δ are from question 3a.

SolveRewrite : Γ = {C, E, G, H, N, O, U, V, Y}and Δ = {A, C, D, G, H, N, O, T, U}The union:

Γ ∪ Δ = {x U| x Γ ∈ ∈ ꓦ x Δ }∈

=> Γ Δ = {A, C, D, E, G, H, N, O, T, U, V, Y}The intersect:

Γ ∩ Δ = {x U| x Γ ∈ ∈ ꓦ x Δ }∈ => Γ Δ = {C, G, H, N, O, U}The non-symmetric difference:

Δ \ Γ = {x U| x Δ ∈ ∈ ꓦ x Γ }∉ => Δ \ Γ = {E, V, Y}

The symmetric difference:

Γ ⊖ Δ = {x U| x Δ x Γ }∈ ∉ ⊕ ∉ => Γ Δ = {A, E, D, T, V, Y}⊖

Trang 13

Question 4: Relations

Let be a binary relation defined on 2 integers as follow: ℜ∀∀ , � ∈ N (aRb↔� |(�.�))where m is the last 2 digits of your student ID.

Is R reflexive, symetric, anti-symetric, transitive? Prove your answer.Solve

By definition of R, this means that

For every a N , 65|(a.a),∈

which is false because a.a = a and a N such that 65 a As a counterexample, let a2

∃ ∈ ∤ 2

= 4 a = 16 and 652 ∤16Hence R is not reflexive.

R is symmetric: To show that R is symmetric, it is necessary to show that For every a N, if aRb then bRa∈

By definition of R, this means that

For every a N, if 65|(a.b) then 65|(b.a)∈

which is true because a.b = b.a by the commutative law of multiplication F1(A-1 Epp)Hence R is symmetric.

Trang 14

R is not anti-symmetric: To show that R is anti-symmetric, it is necessary to show that For every a N, if aRb and bRa then b = a∈

By definition of R, this means that

For every a N, if 65|(a.b) and 65|(b.a) then b = a∈

which is false because 65|(a.b) and 65|(b.a) but a and b can be different As acounterexample, a = 1 and b = 65 then 65|(a.b) and 65|(b.a) but 1 ≠ 65.

Hence R is not anti-symmetric.

R is not transitive: To show that R is transitive, it is necessary to show thatFor every a ,b, c N, if a R b and b R c then a R c∈By definition of R, this means that:

For every a,b,c N, if 65|(a + b) and 65|(b+ c) then 65|(a + c).∈

which is false because a = 42, b = 23, c = 107 then 2|(a + b) and 2|(b+ c) but 65 (a + c).∤Hence R is not transitive.

Question 5: Multiplicative invertion

a Study and present your knowledge about Extended Euclidean algorithm to compute multiplicative inverses in modular structures.

The version of the Euclidean algorithm described above (and by Euclid) can take many subtraction steps to find the GCD when one of the given numbers is much bigger than the other A more efficient version of the algorithm shortcuts these steps, instead replacing the larger of the two numbers by its remainder when divided by the smaller of the two (with this version, the algorithm stops when reaching a zero remainder) With this improvement, the algorithm never requires more steps than five times the number of digits (base 10) of the smaller integer.

Trang 15

b Apply the algorithm to find (m+1) (mod 101) where m is the last 2 digits of your-1

student ID

SolveStudentID : 52000765 m = 66

(m+1) (mod 101) = 66 (mod 101)–1-1

Let’s trace Euclid’s algorithm to calculate gcd(66,101)101 = 66 + 35

66 = 35 + 31 35 = 31 + 4 31 = 4*7 + 3 4 = 1*3 + 1Thus gcd(66,101) = 1 1 = 4 – 1.3 = 4*8 – 31 = 8*35 – 9*31

= 8*(101 – 66) – 9*(66 – 35) = 8*(101 – 66) – 9*[66 – (101 – 66)] = –26*16 + 17*101

Thus 1 = (-26)*66 + 17*1011 = (-26)*66 + 17*101(mod 101)=> 1 ≡ (-26)*66 (mod 101)

66-1 = -26 mod 101 = (-26 + 101) mod 101 = 75 mod 101

Trang 16

Question 6: Kruskal’s Algorithm

Propose a solution for circuit-checking in Kruskal's algorithm.Solve

This is a graph example to find a solution for circuit-checking in Kruskal’s algorithm as follow:

Trang 17

Step 1: Remove all loops and ParallelEdges (*Note: In case of parallel edges, keep theone which has the least cost associated and remove all others).

Step 2: Create a set of edges and weight, and arrange them in an ascending order ofweightage (cost).

B,D D,T A,C C,D C,B B,T A,B S,A S,C

Step 3: Add the edge which has the least weightage.

Now we start adding edges to the graph The least cost is 2 and edges involved are B,Dand D,T We add them Adding them does not violate spanning tree properties, so wecontinue to our next edge selection.

Trang 18

Next cost is 3, and associated edges are A,C and C,D We add them again

Trang 19

Next cost in the table is 4, and we observe that adding it will create a circuit in thegraph So we ignore it In the process we shall avoid all edges that create a circuit.

We observe that edges with cost 5 and 6 also create circuits We ignore them and moveon Now we are left with only one node to be added Between the two least cost edgesavailable 7 and 8, we shall add the edge with cost 7 By add edge S,A we haveminimumcos spanning tree.

Trang 20

Question 7: Eulerian circuit

a Does the following graph have an Eulerian circuit or Eulerian path? Why?

The graph have Eulerian circuit the graph have an Eulerian path that starts and ends onthe same vertex (this thing is proven in c) and a necessary conditional for the existenceof Eulerian circuit is that all vertives in the graph have an even degree, and statedwithout proof that connected graphs with all vertives of even degree have an Euleriancircuit The first complete proof of this latter claim was published posthumously in1873 by Carl Hierholzer

Thus, the graph don’t have Eulerian path.

Trang 21

b Study and present your knowledge about Hierholzer’s algorithm to find an Eulerian circuit.

We start with a random node and then follows an arbitrary unvisited edge to a neighbour This step is repeated until one returns to the starting node This yields a firstcircle in the graph If this circle covers all nodes it is an Eulerian cycle and the algorithm is finished

Otherwise, one chooses another node among the cycles' nodes with unvisited edges and constructs another circle, called subtour By choice of edges in the construction the new circle does not contain any edge of the first circle, both are disjunct However, both circles must intersect in at least one node by choice of the starting node of the second circle Therefore one can represent both circles as one new circle To do so, one iterates the nodes of the first circle and replaces the subtour's starting node by the complete node sequence of the subtour Thus, one inegrates additional circles into the first circle If the extended cycle does include all edges the algorithm is finished Otherwise, we can find another cycle to include.

In the case of an undirected, semi-Eulerian graph the algorithm starts with one of the two nodes with odd degree In the directed case with the node with one additional outgoing edge One of the subtours to be found will then not form a cycle, instead it will also be a path When integrating this "subtour" into the circle one has to make surethat start and end node of this path also form start and end of the complete Eulerian path.

Trang 22

c If the graph has an Eulerian circuit, use Hierholzer's algorithm to find an Eulerian circuit of that graph when the initial circuit R1 is:

SolveStudent ID : 52000765 abcd % 4 = 1 R1 is abhga.The initial circuit R1: a b h g a

Circuit R2: a U V P Q L R F A L K A J K P O U T N O J I A E I N M E B M S B Y e B G e f k G D k l D m n D H

n i j C H j d c b V W Q R F C R X C d X W c i h m l g f Z Y S T Z a.Completed Eulerian circuit:

a b h g a U V P Q L R F A L K A J K P O U T N O J I A E I N M E B M S B Y e B G e f k G D k l D m

n D H n i j C H j d c b V W Q R F C R X C d X W c i h m l g f Z Y S T Z a.

Trang 23

Question 8: Map Coloring

Give this map:

Trang 24

a Modeling this map by a graph.

Trang 25

Step 1: Choose Orissa vertex and color it with Red.

Trang 27

Detail: Look at the graph, we can see vertices like: West Bengal, Jharkhand,Chhattisgarh, Telangana, Andhra Prahdesh adjacent with Orissa so we can colour themsame color.

Repeat this thing and priority is given to vertices of higher degree So we colorUttar Pradesh(9), Maharashtra(7), Assam(7) same colour with Orrisa, and we checkcontinue to the non-adjacent vertices, and we can colour vertices like: Laskshadweep,Andaman and Nicobar Islands, Tamil Nadu, Daman and Diu, Punjab and Sikkim samecolour with Orrisa

Trang 28

Step 3: Choose a new color (Yellow, Blue, Green,…v.v), and repeat what we did inStep 2 for vertices not already colored.(The second color is Yellow, the third color isGreen and the final color is Blue).

Trang 29

Step 4: Repeat Step 2 until all vertices are colored.

Trang 30

All vertices is colored.

Trang 31

TÀI LIỆU THAM KHẢO

Tiếng Việt

1 Đại học Tôn Đức Thắng – Tài liệu lý thuyết môn Cấu Trúc Rời Rạc.

2 Thien Hoang (tvhoang.com) – Thuật toán Euclid mở rộng, Nghịch đảo Modulo, và Định lý số dư Trung Quốc

3 Chuong Le Hoang (wordpress.com) – Thuật toán Kruskal – Tìm cây bao trùmnhỏ nhất

Tiếng Anh

4 GeeksforGeeks – Euclidean algorithms (Basic and Extended)

5 Javatpoint – Kruskal's Algorithm

6 GeeksforGeeks – Eulerian path and circuit for undirected graph.

7 GeeksforGeeks – Hierholzer's Algorithm for directed graph.8 Dr Rhyd Lewis – Cardiff School of Mathematics, Cardiff University.9 Lewis, R (2015) – A Guide to Graph Colouring: Algorithms and

Applications Berlin, Springer.

Trang 32

PHỤ LỤC

Ngày đăng: 07/05/2024, 16:20

Tài liệu cùng người dùng

Tài liệu liên quan