0

I have this Java code for matrix multiplication:

double[][] product(double[][] x, double[][] y) {
    double[][] z = new double[x.length][y[0].length];
    for (int i = 0; i < x.length; i++) {
        for (int j = 0; j < y[0].length; j++) {
            double sum = 0.0;
            for (int k = 0; k < x[0].length; k++) {
                sum += x[i][k]*y[k][j];
            }
            z[i][j] = sum;
        }
    }
    return z;
}

What is the time complexity of this algorithm ? Can I say it is O(n^3) ?

0

1 Answer 1

1

Yes I think it is O(n^3) since you have three loops inside each other

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.