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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started