JAVA - algorithm analysis and sorting
Question 1
Which of the following features grows fastest?
1. N2
2. log N
3. N log N
4. N
5. 10
Question 2
Given the following code segment:
for( int i = 1; i < n; i++ ) for( int j = 1; j < i; j++ ) k = k + i + j;
What is the runtime of the code segment?
1. None of the above
2. O(i*N)
3. O(N2)
4. O(N4)
5. O(N)
Question 3
The runtime for the following code is:
for (i = 1; i <= n; i++) { for (j = 1; j <= n-1; j++) { k = k + i + j; } } for (i = 1; i <= n; i++) { m = m + i; }
1. O(N2 + N)
2. O(N3)
3. O(N)
4. O(N2)
Question 4
Analyzing algorithm efficiency is
1. To estimate execution time
2. To measure exact execution time
3. To find the average driving time
4. To estimate the degree of growth in the form of a function
Question 5
Which of the following complexities is nlogn
1. 23nlogn + 50
2. 23n + 68logn
3. 45n + 45nlogn + 503
4. 300n + 400n*n
5. n*n*n + nlogn
Question 6
The approach searches incrementally for a candidate. As soon as one finds out that this will not provide a solution, look for a new candidate.
The approach is called. ( several answers possible)
1. Backtracking
2. Recursion
3. Divide-and-conquer
4. Brute-force
5. Dynamic programming
Question 1 N2 features grows fastest Answer: 1. N2 Question 2 Runtime of the code segment is O(N2) Answer: 3. O(N2) Question 3 Runtime of the code segment is O(N2) Answer: 4. O(N2) Question 4 Analyzing algorithm efficiency is To estimate the degree of growth in the form of a function Answer: 4. To estimate the degree of growth in the form of a function Question 5 23nlogn + 50, 45n + 45nlogn + 503 are of complexities nlogn Answer: 1. 23nlogn + 50 3. 45n + 45nlogn + 503 Question 6 The approach searches incrementally for a candidate. As soon as one finds out that this will not provide a solution, look for a new candidate. The approach is called Backtracking Answer: 1. Backtracking
Get Answers For Free
Most questions answered within 1 hours.