English 中文(简体)
该法典的执行时间增长率是多少? [闭门]
原标题:What is execution time growth rate Big O of this code? [closed]

该法典的执行时间增长率是多少?

int maxValue = m[0][0];         
for (int i = 0; i < N; i++)         
{                       
    for (int j = 0; j < N; j++)         
    {                       
        if ( m[i][j] > maxValue )           
        {                       
            maxValue = m[i][j];         
        }                       
    }                       
}                   
cout << maxValue << endl;           
int sum = 0;                    
for (int i = 0; i < N; i++)         
{                       
    for (int j = 0; j < N; j++)         
    {                       
        sum = sum + m[i][j];            
    }                       
}                           
cout << sum << endl;                            
最佳回答

O(N^2)是因为你有两套“用于”从0到N的通道。

问题回答

暂无回答




相关问题
Hamiltonian circuit

what is the Big-o complexity of finding a Hamiltonian circuit in a given order Markov chain using DFS?

Best practices for regex performance VS sheer iteration

I was wondering if there are any general guidelines for when to use regex VS "string".contains("anotherString") and/or other String API calls? While above given decision for .contains() is trivial (...

Worst case running time (Big O)

I have this question, and I don t know how to solve it, because I don t understand it. :( The question is: Programs A and B are analyzed and are found to have worst case running times no ...

How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

What s my Big O?

My program of sorting values clocks at: 100000 8s 1000000 82s 10000000 811s Is that O(n)?

热门标签