For a loop where the such function aFunction() inside the loop has a big-o of O(nlog(n)), how do you determine the worst case time complexity?
i ← 0
while (i < n)
aFunction(...)
i ← i+1
done
For a loop where the such function aFunction() inside the loop has a big-o of O(nlog(n)), how do you determine the worst case time complexity?
i ← 0
while (i < n)
aFunction(...)
i ← i+1
done
Think about how much total work is being done here. Each call to aFunction
takes time O(n log n) and you're calling it a total of n times. Overall, that makes for a total of O(n2 log n) total work.
Hope this helps!