I am confused about how Big-O works when working with functions inside functions (when analyzing the worst case). For example, what if you have something like:
for(int a = 0; a < n; a++)
{
*some function that runs in O(n*log(n))*
for(int b = 0; b < n; b++)
{
*do something in constant time*
}
}
Will this whole block work in O (n ^ 2 * log (n)), because in the first for loop you have O (n) and O (n * log (n)), so O (n * log ( n)) more, and therefore the one we take? Or is it O (n ^ 3 * log (n)) because you have O (n) and O (n * log (n)) inside the outer loop?
Any help is appreciated! Thank!
Mason source
share