//assuming lower_bound function runs in O(1)times
//since no description is given about it
line 10: A
line 8-11:A
Line 6:A
line 7:A
line 6-11:A
line 4-12:B
line 3:A
line 13:A
line 1-14:B
//note each single instruction is executed in constant time hence
it is O(1)
Consider the following code: *How many elements in the array A are * also in the...
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....
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....
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)....
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)
What elements does the array numbers contain after the following code is executec int[] numbers = new int [8]; numbers [1] = 3; numbers [4] = 99; numbers [7] = 2; int x = numbers[1]; numbers(x) = 44; numbers (numbers [7]] = 11; O 13, 11, 44, 99, 2] O 10, 3, 11, 44, 99, 0, 0, 2] O 13, 0, 11, 44, 99, 0, 21 O 10, 3, 2, 44, 99, 0, 0, 11]
Question 1 (25 pts)
Find the running time complexity for the following code
fragments. Express your answers using either the Big-O or Big-Θ
notations, and the tightest bound possible. Justify your
answers.
for(int count O , i -0; i < n* n; i++) for(int i0 ; j <i; j++) count++
for(int count O , i -0; i
How can I write this code (posted below) using vectors instead of arrays? This is the task I have and the code below is for Task 1.3: Generate twenty random permutations of the number 0, 1, 2, ..., 9 using of the algorithms you designed for Task 1.3. Store these permutations into a vector and print them to the screen with the additional information of unchanged positions and number of calls torand(). Calculate the total numbers of unchanged positions. Compare...
(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...
Array manipulation (a) Write Java code for a method exchange (int [] a, int i, int j) that exchanges the values stored at indices i and j in the array a. You do not need to worry about cases where either i or j is an invalid index. Give the best estimate you can for its time complexity (b) In an ordered array of n items, how can we determine whether or not an item belongs to the list using...
What is wrong with the following code that prints out the elements of a 2x3 array? for (int i 0; i < 3; ++i) { for (int j = 0; j < 2: ++j) { printf("x(%d] [%d] ". %.2f\n", i, j, x[i][j]); O Expression ali]li] is incorrect O There is nothing wrong with the code 0 %2t is invalid O It is printing for a 3x2 array