Question text DP graph algorithms Recall Bellman-Ford. We provide it below, as given in the course notes. [table] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function BELLMAN_FORD(G = (V, E), s) dist[1..n] = ∞ pred[1..n] = null dist[s] = 0 for k = 1 to n − 1 do for each edge e in E do RELAX(e) print(dist) // This line was added for the test return dist[1..n], pred[1..n] function RELAX((u, v)) if dist[v] > dist[u] + w(u, v) then dist[v] = dist[u] + w(u, v) pred[v] = u [/table] Given input graph and edge relaxation order: [table] -2 4 5 0 -3 -2 -3 4 2 1 s a b c d | b → c b → d s → a a → d s → b b → a a → b a → c d → c c → a [/table] Give the dist array as printed on line 8 after a single iteration (k=1). Note: If a node's distance is infinity, type inf or infinity. [table] | s | a | b | c | d Print after k = 1: | Answer 1 Question 4 | Answer 2 Question 4 | Answer 3 Question 4 | Answer 4 Question 4 | Answer 5 Question 4 [/table]多项填空题

题目图片

登录即可查看完整答案

我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。

类似问题

Question text Consider the following variant of the Bellman-Ford algorithmand the following weighted directed graphLet S be the source vertex for the execution of the Bellman-Ford algorithm. If the edges are relaxed in the following order (S, A), (B, C), (S, D), (S, B), (D, C), (E, D), (A, B), (S, E), -- what is the distance estimate for all the vertices after two iterations of the outer loop of the algorithm are finished? Just type the numerical answer (1,2,3,...) or inf. First iteration [table] Vertex | S | A | B | C | D | E Distance | 0 | Answer 1 Question 1 | Answer 2 Question 1 | Answer 3 Question 1 | Answer 4 Question 1 | Answer 5 Question 1 [/table] Second iteration [table] Vertex | S | A | B | C | D | E Distance | 0 | Answer 6 Question 1 | Answer 7 Question 1 | Answer 8 Question 1 | Answer 9 Question 1 | Answer 10 Question 1 [/table]

Question text Consider the following variant of the Bellman-Ford algorithmand the following weighted directed graphLet S be the source vertex for the execution of the Bellman-Ford algorithm. If the edges are relaxed in the following order (S, A), (B, C), (S, D), (S, B), (D, C), (E, D), (A, B), (S, E), -- what is the distance estimate for all the vertices after two iterations of the outer loop of the algorithm are finished? Just type the numerical answer (1,2,3,...) or inf. First iteration [table] Vertex | S | A | B | C | D | E Distance | 0 | Answer 1 Question 1 | Answer 2 Question 1 | Answer 3 Question 1 | Answer 4 Question 1 | Answer 5 Question 1 [/table] Second iteration [table] Vertex | S | A | B | C | D | E Distance | 0 | Answer 6 Question 1 | Answer 7 Question 1 | Answer 8 Question 1 | Answer 9 Question 1 | Answer 10 Question 1 [/table]

Question text DP graph algorithms Recall Bellman-Ford. We provide it below, as given in the course notes. [table] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | function BELLMAN_FORD(G = (V, E), s) dist[1..n] = ∞ pred[1..n] = null dist[s] = 0 for k = 1 to n − 1 do for each edge e in E do RELAX(e) print(dist) // This line was added for the test return dist[1..n], pred[1..n] function RELAX((u, v)) if dist[v] > dist[u] + w(u, v) then dist[v] = dist[u] + w(u, v) pred[v] = u [/table] Given input graph and edge relaxation order: [table] -2 4 5 0 -3 -2 -3 4 2 1 s a b c d | b → c b → d s → a a → d s → b b → a a → b a → c d → c c → a [/table] Give the dist array as printed on line 8 after a single iteration (k=1). Note: If a node's distance is infinity, type inf or infinity. [table] | s | a | b | c | d Print after k = 1: | Answer 1 Question 4 | Answer 2 Question 4 | Answer 3 Question 4 | Answer 4 Question 4 | Answer 5 Question 4 [/table]

Question text Consider the following variant of the Bellman-Ford algorithmand the following weighted directed graphLet S be the source vertex for the execution of the Bellman-Ford algorithm. If the edges are relaxed in the following order (S, A), (B, C), (S, C), (S, B), (D, C), (E, D), (A, B), (S, E), -- what is the distance estimate for all the vertices after two iterations of the outer loop of the algorithm are finished? Just type the numerical answer (1,2,3,...) or inf. First iteration [table] Vertex | S | A | B | C | D | E Distance | 0 | Answer 1 Question 1 | Answer 2 Question 1 | Answer 3 Question 1 | Answer 4 Question 1 | Answer 5 Question 1 [/table] Second iteration [table] Vertex | S | A | B | C | D | E Distance | 0 | Answer 6 Question 1 | Answer 7 Question 1 | Answer 8 Question 1 | Answer 9 Question 1 | Answer 10 Question 1 [/table]

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!