I've an algorithm: (a1,...,an)(b1,...,bn)(c1,...,cn) x <- 0 for i <- 1 to n do for j <- 1 to n do for k <- 1 to n do x <- x + (ai * bj * ck^2) return x
So considering there are 3 for loops that would so far make the running time O(n^3) right? But for the final loop the statement points to different spots in each of the arrays, i j and k (not sure if this actually makes any difference). And furthermore there is a square within the final loop, and I've seen things about squares within the loops multiplying the polynomial a fair bit, leading me to think the run time is O(n^5) as I'm assuming it would be n^3 * n^2?
This is probably more suited for stackoverflow programming forum.
Three loops make it O(n^3).
Arrays are made so that access is O(1) => constant doesn't depend on n.
Multiplication is also O(1).
So the final run time complexity is O(n^3).