Solution:
Question No 01 Solution
Part A:
for (i = 1 ; i<= n; i++)……n times
{
for (i = 1 ; i<= n2 ; i++)…….n2 times
{
for (i = 1 ; i<= n3 ; i++)……n3 times
{
a = x+y;……. Constant c
}
}
}
T(n)=n*n2*n3+c
T(n)=n6+c
T(n)=n6
Part B:
for ( y = 1 ; y <= n; i++)……n times
{
for (i = 1 ; i<= n2 ; i++)…….n2 times
{
for (i = 1 ; i<= n3 ; i++)……n3 times
{
a = x+y;……. Constant c
}
}
}
T(n)=n*n2*n3+c
T(n)=n6+c
T(n)=n6
Question No 02 Solution
matrix (int rows, int columns)
array matrix [rows][columns]
for i 1 to rows…….n times{
do for j 1 to columns…….n times{
do print Matrix[rows][columns]tab;
}
print endline;
T(n)=n*n=n2