Thursday, August 1, 2019

Arithmetic Q

Question 1: Consider the following graph G. [pic] 1. Give the adjacency matrix and adjacency list of the graph G. (5 marks) adjacency matrix: [pic] adjacency list: |a | | b | |c | | d | |e | |f | b d a c e b e f a e b c d f c e 2. Give the incidence matrix and incidence list of the graph G. (5 marks) [pic] incidence matrix [pic] incidence list |1 | | 2 | |3 | | 4 | |5 | |6 | a b a d b c b e c e c e |7 | 8 | d e e f Question 2: Consider the graph I. Starting at the vertex a and resolving ties by the vertex alphabetical order traverse the graph by breadth-first-search (BFS) and construct the corresponding BFS tree. (5 marks) [pic] The order is : a b e g f c d h II. Starting at the vertex a and resolving ties by the vertex alphabetical order traverse the graph by depth-first-search (DFS) and construct the corresponding BFS tree. (5 marks) [pic] The order is : a b f e g c d h Question 3: Consider the following graph G.The label of an edge is the cost of the edge. 1. Using Prim's algorith m, draw a minimum spanning tree (MST) of the graph Also write down the change of the priority queue step by step and the order in which the vertices are selected. Is the MST drawn unique? (i. e. , is it the one and only MST for the graph? ) [7 marks] Not unique [pic] 2. Using Kruskal’s algorithm, draw a minimum spanning tree (MST) of the graph G. Write down the order in which the edges are selected. Is the MST drawn unique? (i. e. , is it the one and only MST for the graph? ) (5 marks)Not unique [pic] 3. Referring to the same graph above, find the shortest paths from the vertex a to all other vertices in the graph G using Dijkstra’s algorithm. Show the changes of the priority queue step by step and give the order in which edges are selected. (8 marks) [pic] Order in which edges are selected: a-e, e-f, a-b, f-g, b-c, g-h, c-d the shortest paths from the vertex a to all other vertices: a. b: 4 a. c: 10 a. d:17 a. e:1 a. f:3 a. g:8 a. h: 16 N. B. There may be more than on e solution. You only need to give one of the solutions.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.