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

  1. what author mean idea " exploit relationship between problem , simpler rather smaller version" please elobaorate.

  2. 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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -