QUESTION 8
What is the worst-case complexity of line 7 of function bar?
A.
O(1)
B.
O(N)
C.
O(i)
D.
O(log N)
E.
O(sqrt N)
F.
O(A[i])
G.
O(N sqrt N)
H.
O(N log N)
I.
O(N^2)
J.
O(i^2)
K.
None of the above
QUESTION 9
What is the worst-case complexity of lines 6-11 of function bar?
A. |
O(1) |
|
B. |
O(N) |
|
C. |
O(i) |
|
D. |
O(log N) |
|
E. |
O(sqrt N) |
|
F. |
O(A[i]) |
|
G. |
O(N sqrt N) |
|
H. |
O(N log N) |
|
I. |
O(N^2) |
|
J. |
O(i^2) |
|
K. |
None of the above |
QUESTION 10
What is the worst-case complexity of lines 4-12 of function bar?
A. |
O(1) |
|
B. |
O(N) |
|
C. |
O(i) |
|
D. |
O(log N) |
|
E. |
O(sqrt N) |
|
F. |
O(A[i]) |
|
G. |
O(N sqrt N) |
|
H. |
O(N log N) |
|
I. |
O(N^2) |
|
J. |
O(i^2) |
|
K. |
None of the above |
QUESTION 8 Time complexity of binary search is O(logn) Line 7 runs for n times. So, total time complexity = O(nlog(n)) Answer: O(N log N) QUESTION 9 Time complexity of sequentialOrderSearch is O(n) Each Line from 6-11 runs for n times. So, total time complexity = O(n*n) = O(n^2) Answer: O(N^2) QUESTION 10 Time complexity of sequentialOrderSearch is O(n) Each Line from 4-12 runs for n times. So, total time complexity = O(n*n) = O(n^2) worst-case complexity of lines 4-12 of function bar = O(n^2) Answer: O(N^2)
QUESTION 8 What is the worst-case complexity of line 7 of function bar? A. O(1) B....
QUESTION 5 What is the worst-case complexity of line 10 of function bar? A. O(1) B. O(N) C. O(i) D. O(log N) E. O(sqrt N) F. O(A[i]) G. O(N sqrt N) H. O(N log N) I. O(N^2) J. O(i^2) K. None of the above QUESTION 6 What is the worst-case complexity of lines 8-11 of function bar? A. O(1) B. O(N) C. O(i) D. O(log N) E. O(sqrt N) F. O(A[i]) G. O(N sqrt N) H. O(N log N) I....
Which big-O expression best characterizes the worst case time complexity of the following code? public static int foo(int N) ( int count = 0; int i1; while (i <N) C for (int j = 1; j < N; j=j+2) { count++ i=i+2; return count; A. O(log log N) B. O(log N2) C. O(N log N) D. O(N2)
Using C++ please explain What is the Big-O time complexity of the following code: for (int i=0; i<N; i+=2) { ... constant time operations... Select one: o a. O(n^2) O b. O(log n) c. O(n) O d. 0(1) What is the Big-O time complexity of the following code: for(int i=1; i<N; i*=2) { ... constant time operations... Select one: O O a. O(n^2) b. 0(1) c. O(n) d. O(log n) O What is the Big-O time complexity of the following...
2.1 Given an unsorted std::vector<int> and a number n, what is the worst-case time complexity for finding the pair of integers whose sum is closest to n, using no additional memory? For example, given the vector {12, 3, 17, 5, 7} and n = 13, we would get the pair {5, 7}.
Show your work Count the number of operations and the big-O time complexity in the worst-case and best-case for the following code int small for ( i n t i = 0 ; i < n ; i ++) { i f ( a [ i ] < a [ 0 ] ) { small = a [ i ] ; } } Show Work Calculate the Big-O time complexity for the following code and explain your answer by showing...
1). What is the complexity of the following code snippet? { for (int count2 = 0; count2<n; count2++) { /*some sequence of O(1) step*/ } } select one: a. O(N^2) b. O(Log N) c. O(1) d. O(N!) 2). What is the complexity of the following code snippet? for (int count = 0; count<n; count++) { printsum(count) } select one: a. We need to know the complexity of the printsum() function. b. O(Log N) c. O(1) d. O(N) e. O(N^2) 3)....
(10') 6. For each of the following code blocks, write the best (tightest) big-o time complexity i) for (int i = 0; ǐ < n/2; i++) for (int j -0: ni j++) count++ i) for (int í = 0; i < n; i++) for (int ni j0 - for (int k j k ni kt+) count++ İİİ) for (int í ー 0; i < n; i++) for(int j = n; j > 0; j--) for (int k = 0; k...
Consider the following code: *How many elements in the array A are * also in the array B? Assume B is sorted. */ 01: int overlap (int* A, int* B, int N) 02:{ 03: int count = 0; 04: for (int i = 0; i < N; ++i) 05: 06: int x A [i 07: 08 int pos lower_bound (B, B+N, x) - B; if (pos N && B [pos] 09: 10: 11: 12: == x ) { +count; 13:...
The time-complexity of searching an AVL tree is in the worst case and in the average case. On), On) O(logot). O(log O ON), C(n) 0(), O(log) Question 16 2 pts The time-complexity of searching a binary search tree is in the worst case and in the average case (1), O(log) O(logn), O(log,n) On), On) 001), 001)
FOR ALGORITHM A WORST CASE TIME COMPLEXITY IS DESCRIBED BY RECURRENCE FORMULA T(n)= n/ T (n )thi T (c)=1 if c < 100 FOR ALGORITHM B WORST TIME COMPLEXITY IS DESCRIBED BY RECURRENCE FORMULA T(n) = 2T (2/2) + n/logn ; (c) = 1 fc 2100 WHICH ALGORITHM IS ASYMPTOTICALLY FASTER? WHY?