+ 1

What is the time complexity in this example;

consider a function that takes in a2 dimentional array as an argument of size n x m(n=columns and m= rows). //the function: int sum_up(int Array[][],unsigned n, sunsigned m){ int ret=0; for(unsigned i=0;i<n;i++) for(unsigned j=0;j<m;j++) ret+=Array[i][j]; return ret; } Is the time complexity T=O(nm)?

20th Mar 2020, 9:25 PM
xaralampis_
xaralampis_ - avatar
1 Réponse
+ 3
Yes, the big O for your function is O(nm), as there are nm iterations.
20th Mar 2020, 11:13 PM
Adam McGregor