Write the algorithm that finds and returns how many paths in k units of length between any given two nodes (source node, destination node; source and target nodes can also be the same) in a non-directional and unweighted line of N nodes represented as a neighborhood matrix. (Assume that each side in the unweighted diagram is one unit long.) Note: By using the problem reduction method of the Transform and Conquer strategy, you have to make the given problem into another problem. Algorithm howManyPath (M [0..N-1] [0..N-1], source, target, k) // Input: NxN neighborhood matrix, source, target nodes, k value. // Ouput: In the given line, there are how many different paths of k units length between the given source and target node.
Write the
Note: By using the problem reduction method of the Transform and Conquer strategy, you have to make the given problem into another problem.
Algorithm howManyPath (M [0..N-1] [0..N-1], source, target, k)
// Input: NxN neighborhood matrix, source, target nodes, k value.
// Ouput: In the given line, there are how many different paths of k units length between the given source and target node.

Step by step
Solved in 3 steps









