Consider the following graph:
Apply Dijkstra's and the Bellman-Ford algorithms to the given graph, with node as the source node. In two arrays, write the shortest paths that each of the algorithms outputs: on the first line — Dijkstra's output, and on the second line — the Bellman-Ford output.
The shortest distances in the array should follow this order: If an algorithm finds the presence of a negative cycle, write NC instead.
Answer format example 1:
3 7 2 4
3 7 1 4
Example 2:
NC
NC