c - Warshall algorithm idea and improvement -
the warshall-floyd algorithm based on idea: exploit relationship between problem , simpler rather smaller version. warshall , floyd published algorithms without mentioning dynamic programming. nevertheless, algorithms have dynamic programming flavor , have come considered applications of technique.
algorithm warshall(a[1..n, 1..n]) //implementswarshall’s algorithm computing transitive closure //input: adjacency matrix of digraph n vertices //output: transitive closure of digraph r(0) ←a k←1 n ←1 n j ←1 n r(k)[i, j ]←r(k−1)[i, j ] or (r(k−1)[i, k] , r(k−1)[k, j]) return r(n)
we can speed above implementation of warshall’s algorithm inputs restructuring innermost loop
my question on above text following
what author mean idea " exploit relationship between problem , simpler rather smaller version" please elobaorate.
how can improve speed author mentioned in above implemenation.
the formulation 1. means shortest path problem (which can seen generalization of transitive closure problem) has optimal substructure property; property not exist formal description (in sense of mathematical definition). optimal substructure property necessary problem amenable dynamic programming.
Comments
Post a Comment