Question: DATA STRUCTURES JAVA Given the following program with n as parameter: 0 i = 0; j =0; 1 while(i <1000) 2 for( int k =

DATA STRUCTURES JAVA

Given the following program with n as parameter: 0 i = 0; j =0; 1 while(i<1000) 2 for( int k = i; k <= n; k++ ){ 3 i++; 4 j++;} 5 for( int p = 0; p < n*n; p++ ) 6 for( int q = 0; q < p; q++ ) 7 j; 1. How many times is the instruction 3 executed?

a. O( N ) b. O( N2 ) c. O( N3 ) d. O( N4 ) e. none of the above 2. How many times is statement 7 executed?

a. O( N ) b. O( N2 ) c. O( N3 ) d. O( N4 ) e. none of the above 3. What is the time complexity of the above program?

a. O( N4 ) b. O( N5 ) c. O( N6 ) d. O( N7 ) e. none of the above 4. What is the time complexity of finding the minimum in a random array with N elements? Why?

a. O(N2) b. O(N3) c. O(N) d. O(logN) e. None of these

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!