Calculate the Time complexity and Space complexity of the algorithm given below.
Algorithm Add(Arr1, Arr2, n)
{
for( x=0; x
{
for(y=0; y
{
Arr3[x, y] = Arr1[x, y] + Arr2[x, y];
}
}
}
Answers
Answered by
1
Answer:
Time Complexity = O(n^2)
Space Complexity = O(1)
Explanation:
Due to nested for loops Time Complexity will be quadratic..
whereas there is no need of extra space
hence , Space Complexity will be O(1)
Similar questions