for (i=0; i<n/2; ++i)
for (j=0; j<n*2; j++)
for (k=0; k<100; k++)
m++;
How do you represent this code in Big Five notation?
big-o
The code of the question is not properly highlighted, so it's hard to see.
If n
is an input value in the algorithm,
The last for statement (for(k=0;k<100;k++)
) is not dependent on n
so
Exponential is going to be 2, not 3.
Simplified
O(n/2 * 2n * 100) == O(100n2 ) == O(n2 )
22That is, O (n2).
2
© 2024 OneMinuteCode. All rights reserved.