+ 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)?
1 Réponse
+ 3
Yes, the big O for your function is O(nm), as there are nm iterations.