Sie sind auf Seite 1von 6

2440109114 | Kanzi Katsira Firdausi

Please produce the Adjacency Matrix and the Cost Matrix!

1 2 3 4 5 6 7 8 9

1 0 6 8 0 0 0 0 0 0
2 6 0 2 0 0 0 0 0 0
3 0 2 0 0 0 0 0 0 10
4 0 0 0 0 0 0 0 9 0
5 7 0 0 7 0 0 0 0 0
6 0 0 0 0 0 0 0 2 0
7 0 0 0 0 0 0 0 0 12
8 0 4 0 9 0 2 3 0 0
9 0 0 10 0 0 0 12 0 3

Cost Matrix

1 2 3 4 5 6 7 8 9

1 ∞ 6 8 ∞ ∞ ∞ ∞ ∞ ∞
2 6 ∞ 2 ∞ ∞ ∞ ∞ ∞ ∞
3 ∞ 2 ∞ ∞ ∞ ∞ ∞ ∞ 10
4 ∞ ∞ ∞ ∞ ∞ ∞ ∞ 9 ∞
5 7 ∞ ∞ 7 ∞ ∞ ∞ ∞ ∞
6 ∞ ∞ ∞ ∞ ∞ ∞ ∞ 2 ∞
7 ∞ ∞ ∞ ∞ ∞ ∞ ∞ ∞ 12
8 ∞ 4 ∞ 9 ∞ 2 3 ∞ ∞
9 ∞ ∞ 10 0 ∞ ∞ 12 ∞ 3
• Draw a tree with 14 vertices

• Draw a directed acyclic graph with 6 vertices and 14 edges

• Suppose that your computer only has enough memory to store 40000 entries. Which best graph
data structure(s) – you can choose more than 1 -- should you use to store a simple undirected
graph with 200 vertices, 19900 edges, and the existence of edge(u,v) is frequently asked?

– Adjacency Matrix

– Adjacency List

– Edge List
I would choose Adjancency matrix as a simpler and easily understandable approach, and the second one
I would choose Adjancey list, but I need to be extra careful while checking the existence of edge(u,)
because it requires a lot of time. So out of 3 options that have been given, I would choose 2.

• Do implementation of DFS and BFS for the following graph:

Semuanya mulai dari Nol | DFS

Traversal Order: A B C D H E F G I J L K M N
BFS

Travelsar Order : A B C E H I D F G J M N O P K

Make the steps of the followed the numbers 34, 15, 23, 9, 41, 26, 39, 11, 7, 28 by using Heap Sort!

+34
34

34 15

+15

15

34

15

+23 34 25
+9 15
9

25 15 25
34

34

+41

15
23

34
41

9
+26

23
15

34 41
26

9
9

+26

15 23

34 41 26 39

+39 9
9

11 23

15 23

15 41
26 39
34 39
41 26

34

11

Das könnte Ihnen auch gefallen