I'm debating with a friend whether a particular function I wrote is $O(N^3)$ or $O(N \times M \times X)$
I believe it is the latter since all 3 variables differ in size. $N = 100, M = 50, X = 10000$
for i in range(len(N)):
for j in range(len(M)):
for p in range(len(X)):
if statement:
count += 1
list.append(count)
The outer loop executes $N$ times, the inner loop executes $M$ times, and the most inner loop executes $X$. Hence giving $N \times M \times X$. His theory is that because $X$ is so much greater than the other two variables it makes it $O(N^3)$
append
function take? Are $N$, $M$, and $X$ constants or variables? $\endgroup$ – ryan Jun 6 '19 at 17:14append
is $O(1)$ and $N, M$ and $X$ are all variables. $\endgroup$ – bogdboa Jun 6 '19 at 17:17