1、Counting Primitive Operations
void STRAITMAXMIN(A,n,max,min) //Set the maximum value in A to max and the minimum value to min
{ int i,n
max=min=A[1]
for i=2 to n
{
if A[i]> max
max=A[i];
if A[i]< min
min=A[i];
}
}
What is the number of primitive operations?
2、Please explain the concept of Time Complexity Big-Oh Notation
3. Give an analysis of the running time (Big-Oh will do).
sum = 0;
for( i = 0; i < n; ++i )
for( j = 0; j < n; ++j )
++sum;
4. Give an analysis of the running time (Big-Oh will do).
sum = 0;
for( i = 0; i < n; ++i )
for( j = 0; j < n * n; ++j )
++sum;
5. Give an analysis of the running time (Big-Oh will do).
sum = 0;
for( i = 0; i < n; ++i )
for( j = 0; j < i * i; ++j )
for( k = 0; k < j; ++k )
++sum;
Answers
Answered by
0
Answer:
Counting Primitive Operations
void STRAITMAXMIN(A,n,max,min) //Set the maximum value in A to max and the minimum value to min
{ int i,n
max=min=A[1]
for i=2 to n
{
if A[i]> max
max=A[i];
if A[i]< min
min=A[i];
}
}
What is the number of primitive operations?
2、Please explain the concept of Time Complexity Big-Oh Notation
3. Give an analysis of the running time (Big-Oh will do).
sum = 0;
for( i = 0; i < n; ++i )
for( j = 0; j < n; ++j )
++sum;
4. Give an analysis of the running time (Big-Oh will do).
sum = 0;
for( i = 0; i < n; ++i )
for( j = 0; j < n * n; ++j )
++sum;
5. Give an analysis of the running time (Big-Oh will do).
sum = 0;
for( i = 0; i < n; ++i )
for( j = 0; j < i * i; ++j )
for( k = 0; k < j; ++k )
++sum;
Similar questions