Evaluate the closure of a linkAlgorithmThe time complexity is the fourth power of N. This algorithm is the third power of N, so warshall won the Tulin award.
# Include <iostream. h>
# Include <stdio. h>
# Include <stdlib. h>
Void main ()
{
Int n_dim = 0;
Cout <"input number of dimensions :";
Cin> n_dim;
Char ** array = new char * [n_dim]; // The following figure shows how to dynamically create an n_dim * n_dim array.
Char ch; // another article about Dynamic ArrayArticle
For (INT I = 0; I <n_dim; I ++)
{
Array [I] = new char [n_dim]; // This sentence is also
For (Int J = 0; j <n_dim; j ++)
{
Cin> CH;
Array [I] [J] = CH;
}
}
For (I = 0; I <n_dim; I ++)
For (Int J = 0; j <n_dim; j ++)
For (int K = 0; k <n_dim; k ++)
If (array [I] [J] = '1' & array [k] [I] = '1 ')
Array [k] [J] = '1 ';
Cout <"The trasitive closure of a relation R represented:" <Endl;
For (I = 0; I <n_dim; I ++)
{
For (Int J = 0; j <n_dim; j ++)
Cout <array [I] [J];
Cout <Endl;
}
}