Question: For the following pseudo-codes, what is the time complexity function (T(n)) and the order ()? You can ignore the overhead operations and just count the
For the following pseudo-codes, what is the time complexity function (T(n)) and the order ()? You can ignore the overhead operations and just count the basic operations. For (b), you can assume that n is divisible by 3.
(a) void test ( int n , int A[ ] ) {
index i , j , t ;
for ( i = 1 ; i <= n ; i++)
for ( j = i+1 ; j <= n ; j++)
if (A[j] < A[i]) {
t=A[j];
A[j] = A[i];
A[i] = t;
}
}
(b) for ( i = 0 ; i <= n ; i++) {
for ( j = 0 ; j <= n) {
cout << i << j ;
j = j + floor(n/3);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
