Given a weighted graph below and you are using the Dijkstra algorithm to find the shortest path from the vertex A to the vertex B. What is the label of the vertex D when the shortest path from A to B is determined?

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: "5". Các cung là A sang C nặng 3, A sang D nặng 21, A sang E nặng 6, A sang B nặng 11, C sang D nặng 2, D sang B nặng 5, E sang D nặng 11, E sang B nặng 2. Chạy Dijkstra từ A: cố định A với nhãn 0 rồi cập nhật C bằng 3, E bằng 6, B bằng 11, D bằng 21. Đỉnh tạm nhỏ nhất là C với 3, qua cung C sang D nhãn của D hạ xuống 3 + 2 = 5. Tiếp đó cố định D với 5 và hạ nhãn của B xuống 5 + 5 = 10. Rồi cố định E với 6 và hạ nhãn của B xuống 6 + 2 = 8. Khi B được cố định với 8, tức đường ngắn nhất từ A tới B đã xác định, nhãn của D đang là 5. Con số "21" là nhãn tạm ban đầu lấy từ cung trực tiếp A sang D, bị thay ngay khi C được cố định. Con số "17" ứng với đường qua E là 6 + 11, lớn hơn 5 nên chưa bao giờ được nhận. Phương án "infinity" chỉ đúng nếu D không tới được từ A, nhưng D đã có nhãn hữu hạn ngay từ lần cập nhật đầu tiên.

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ộ đề