You are organizing a programming competition, where contestants implement Dijkstra's algorithm. Given adirected graph G = (V, E) with integer-weight edges and a starting vertex s ∈ V , their programs are supposedto output triplets (v, v.d, v.π) for each vertex v ∈ V . Design an O(V +E) time algorithm that takes as inputthe original graph G in both adjacency matrix (G.M) and adjacency list (G.Adj) representations, startingvertex s, and the output of a contestant's program (given as an array A of triplets), and returns whetherA is the correct output for G. Write down the pseudocode for your algorithm, explain why it correctlyveries the output, and analyze your algorithm's running time. You may assume that all edge weights of the input graph provided to the contestantsare nonnegative and A (the output of their programs) is in the valid format, i.e., you don't need to verifythat A is actually an array of triplets, with v and v.π being valid vertices and v.d being an integer.Can you achieve O(V + E) time if the input graph is given only in the adjacency matrix or only in theadjacency list representation?

icon
Related questions
Question

You are organizing a programming competition, where contestants implement Dijkstra's algorithm. Given a
directed graph G = (V, E) with integer-weight edges and a starting vertex s ∈ V , their programs are supposed
to output triplets (v, v.d, v.π) for each vertex v ∈ V . Design an O(V +E) time algorithm that takes as input
the original graph G in both adjacency matrix (G.M) and adjacency list (G.Adj) representations, starting
vertex s, and the output of a contestant's program (given as an array A of triplets), and returns whether
A is the correct output for G. Write down the pseudocode for your algorithm, explain why it correctly
veries the output, and analyze your algorithm's running time. You may assume that all edge weights of the input graph provided to the contestantsare nonnegative and A (the output of their programs) is in the valid format, i.e., you don't need to verifythat A is actually an array of triplets, with v and v.π being valid vertices and v.d being an integer.
Can you achieve O(V + E) time if the input graph is given only in the adjacency matrix or only in the
adjacency list representation?

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS