Combining Time Complexity

how you would compute/denote the time complexity of two loops based on different variables?
I understand how to compute the time complexity for a simple loop

PseduoCode

while X<N
{
while Y<M
{
Z++

}
X++
}

one loop occurs N times - time complexity O(N)
the other loop occurs M - time complexity 0(M)
M- happens to be a unknown function of N

would the time complexity O(MN)?
but In big O notation you are to drop all excess variables
in which case time complexity would be O(N)?

or neither? please help
i think would be O(N*f(n))

My only question now is, is there any real point to time complexity? I mean granted it helps show how quick or slow an algorithm is but it not it terms of iterations in relations to but they dont fully represent the correct time. Take sort by insertion it time complexity is averages 0(N^2) however, if you are dealing with mostly sorted data, which most programs are it would be (N*D) D-being the number of things need to be inserted. So is there really a point?
You are correct that the time complexity is O(MN). You say that "M happens to be a unknown function of N". Do you know anything about this function? If you can say that N <= M * k is always true for some constant k then you can substitute M with N so we have O(N2). k is removed because it's a constant.

Topic archived. No new replies allowed.