Question: Use the Big O notation to estimate the time complexity of the following methods. a) public static void mA( int n) { for ( int

Use the Big O notation to estimate the time complexity of the following methods.

a)

public static void mA(int n) {

 for (int i = 0; i < n; i++) {
 System.out.print(Math.random());
 }
}
 
b)  
public static void mB(int n) { 
 for (int i = 0; i < n; i++) {
 for (int j = 0; j < i; j++)
 System.out.print(Math.random());
 }
}
 
c)  
public static void mC(int[] m) { 
 for (int i = 0; i < m.length; i++) {
 for (int j = 0; j < i; j++)
 System.out.print(m[i] * m[j]);
 }
}
 
 
d) 
public static void mD(int[] m) { 
 for (int i = 0; i < m.length; i++) {
 System.out.print(m[i]);
 }
 
 for (int i = m.length - 1; i >= 0; )
 {
 System.out.print(m[i]);
 i--;
 } 
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!