I usually am able to answer this sort of question by graphing on Desmos, but I'm having trouble figuring out how to represent these graphs to visualise the difference in steepness, especially as m tends to n and m goes beyond n.
An example where this can come up is "compare two arrays to find if there are any duplicates from the first array in the second array". Here, m
, and n
are the lengths of the arrays. If m and n are equal, then the complexity is n^2
for a nested-loop pairwise comparison solution. But if they are unequal, is the complexity graph 'worse' than n^2
? I can't seem to figure out how to graph this to check, or even express this mathematically.