What is the time complexity of the program for the sum of two matrices?
Step count method
void sum()
{
int n, a[n][n],b[n][n],c[n][n],i,j; //—-0
for(i=0;i<n;i++) //—-n+1
{
for(j=0;j<n;j++) //—-n+1
{
c[i][j]=a[i][j]+b[i][j]; //—-n
}
}
}
f(n) = 0 + (n+1) * (n+1+n)
f(n) = (n+1)*(2n+1)
f(n) = 2n2 + 3n + 1
f(n) = O(n2)