Find Big-O notation for the following algorithm:
Here is the answer..
If there is no break statement in if condition the the Big-O notation for the function is O()
If you have any doubts please COMMENT...
If you understand the answer please give THUMBS UP...
Find Big-O notation for the following algorithm: int function9(int n) { int ij for (i-0; in;...
Big-O notation. Consider the following function. int func1(int n) { int sum = 0, i; for(i = 0; i<n; i++;) { sum += i; return sum; } Express the running time of func1 as a function of n using big-O notation. Write a function that has the same functionality as func1, but runs in O(1) time.
What is the big o cost of this method? int count = 0; int i = 1; while(i < n){ for (j = 1; j < n*n; j *= n) { count++; } i *= 2; } System.out.println(count);
b. what is the order (big -o) of this algorithm? 11. To answer this question, consider the n, consider the following algorithm: for (int i-0; i<ni i++) for (int j = 0; j <= i; j++) // three assignment statements in body of this inner loop a. (6 pts) Exactly how many assignments (in terms of n) are made in this algorithm?
#include<stdio.h> int functionl (int x, int y); int main() int ij=2,k; for(i=1;i<=5; i++) k = function1(ij); printf("k=%d\n",k); return 0; int function] (int x, int y) int z; z=x*2+y; return z;
(V). Given the following algorithm, answer relevant questions. Algorithm 1 An algorithm 1: procedure WHATISTHIS(21,22,...,n: a list of n integers) for i = 2 to n do c= j=i-1 while (j > 0) do if ra; then break end if 4j+1 = a; j= j-1 end while j+1 = 1 end for 14: return 0.02. 1, 15: end procedure Answer the following questions: (1) Run the algorithm with input (41, 02, 03, 04) = (3, 0, 1,6). Record the values...
Please specify Time and Space Complexities in terms of the Big-O notation. for (int j = 1; j < n; j = 2 * j) sum += j; Question 8 options: O(n^2) O(n log n) O(log n) O(n) O(1)
The Big O notation for an algorithm with exactly 50 constant time operations is a. O ( 50 ) b. 0(1) C. 0, 50 N ) d. 50.0(1)
consider this segment of an algorithm: for i := 1 ton n for j:=1 to n top:=ij+j+10 a. find a function f(n) that counts the number of multiplication and additions performed in this segment. b. Give a big O estimate for the number of additions and multiplications used in the segment
find complexity Problem 1 Find out the computational complexity (Big-Oh notation) of the code snippet: Code 1: for (int i = n; i > 0; i /= 2) { for (int j = 1; j < n; j *= 2) { for (int k = 0; k < n; k += 2) { // constant number of operations here } } } Code 2: Hint: Lecture Note 5, Page 7-8 void f(int n) { if (n...
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...