Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex C. What are the correct order of vertices selected into the set S until the vertex C is selected? (Each step a vertex with minimal current distance is selected into S).

4 phương ánCó giải thích

Các phương án trả lời

Chọn một phương án
Lời giảiChọn phương án để mở
Đáp án đúng: "A, B, D, E, C". Các cung là A→B = 2, A→D = 20, A→E = 5, A→C = 10, B→D = 1, D→C = 4, E→D = 10, E→C = 1. Chọn A với khoảng cách 0, cập nhật B = 2, E = 5, C = 10, D = 20. Nhỏ nhất là B = 2 nên B vào S; qua B→D = 1 thì D hạ xuống 2 + 1 = 3. Nhỏ nhất kế tiếp là D = 3 nên D vào S; qua D→C = 4 thì C hạ xuống 3 + 4 = 7. Tiếp đến E = 5 vào S; qua E→C = 1 thì C hạ tiếp xuống 5 + 1 = 6. Cuối cùng C = 6 được chọn, nên thứ tự là A, B, D, E, C. Phương án "A, B, C" coi C = 10 là chốt ngay sau khi A và B vào S, bỏ qua D = 3 và E = 5 đều nhỏ hơn. Phương án "A, B, D, C" bỏ E = 5 dù 5 nhỏ hơn giá trị 7 của C lúc đó, mà chính E mới hạ C xuống 6. Phương án "A, B, E, C" bỏ D = 3, trong khi cung B→D = 1 vừa hạ D xuống 3 nên D phải vào S ngay sau B.

Cùng phần 5

Suppose the graph G = (V,E) satisfies the conditions for the existence of an Eulerian cycle. The following is an algorithm for finding Euler cycle from the vertex X using stack: declare a stack S of characters (a vertex is labeled by a character) declare an empty array E (which will contain Euler cycle) push the vertex X to S while(S is not empty) {ch = top element of the stack S if ch is isolated then remove it from the stack and put it to E else select the first vertex Y (by alphabet order), which is adjacent to ch,push Y to S and remove the edge (ch,Y) from the graph } the last array E obtained is an Euler cycle of the graph Suppose a multigraph G is given below (view picture). Which of the followings is the Euler cycle from the vertex B, created by above algorithm?Có lời giảiCâu hỏiGiven the graph G = (V,E) and X is a vertex of G. Suppose there exists at least one Hamilton Cycle for the graph. The following is a backtracking algorithm for finding the first Hamilton cycle from the vertex X: declare an empty array H (which will contain Hamilton cycle) (1) Put the vertex X to H (2) Check if H is a Hamilton cycle then stop, else go to (3) (3) Consider the last vertex Y in H, if there is/are vertex(es) adjacent to Y, select the first adjacent vertex Z (by alphabet order) and put it to H. If there no adjacent vertex, remove Y from H and denote it as a bad selection (so you do not select it in the same way again). Go to (2). Suppose a G is given below (view picture). Which of the followings is the Hamilton cycle from the vertex A, created by above algorithm?Có lời giảiCâu hỏiWhat data structure is used for breadth first traversal of a graph?Có lời giảiCâu hỏiCả 48 câu của chủ đề48 câu

Xuất hiện trong 1 bộ đề