Then For every value of
, expression
will run
times.
So for
will run
times.
for
will run
times
and so on..
Therefore :
Total times
will run is
so
Find - notation in terms of n for the pseudocode below. Provide a short answer. for...
Describe the worst case running time of the following
pseudocode functions in Big-Oh notation in terms of the variable n.
Show your work
b) void func(int n) { for (int i = 0; i < n; i = i + 10) { for (int j = 0; j < i; ++i) { System.out.println("i = " + i); System.out.println("j = " + j);
10 pts Question 2 Find 0 - notation (as a function of n) for the number of times the statement "x x +1" is executed in the following pseudocode: for i 1 to n3 for j 1 to i х%3Dх+1
Find ⊝ - notation for the expression:
Find - notation for the expression: (1+2+...+n) lgn + 81nlg? n + ()" + 2256 2256 on? Ign 21 n3 nlgn nlgn (1)"
[10 marks] consider the following pseudocode: p := 0 x := 2fori:= 2ton p := (p + i ) * x a) How many addition(s) and multiplication(s) are performed by the above pseudocode?b) Express the time-complexity of the pseudocode using the big-Θ notation.) Trace the algorithm, below, then answer (c) and (d): Procedure xyz(n: integer) s := 0, for i:= 1 to n, for j:= 1to i, s:= s+ j*(i− j+ 1) return s c) What is the time-complexity for...
se Factorial Notation Question Write the first three terms of the sequence whose general terms an--(n-1)! 2 Provide your answer below: 4 Previous
Explain please
II. (7 points) Consider the following bit of pseudocode: for (int k = 1; ks Ign; k++) (for (int i = 1; i r: i++) Print "Hello World"; for (int j-1;jsn:j++) Print "Hello World" when n = 2, how many times will "Hello World" be printed? When n 4, how many times will "Hello World be printed? O Assuming that the print is the basic operation, what is the complexity function of this pseudocode?
II. (7 points) Consider...
Provide the Big‐O notation for the following lines of Java code, make sure you include all the necessary steps to reach your answer to receive any credit: a. for (i = 10; i < n – 8; i++) { for( j = 1; j < m; j *= 2) x = i + j; } b. for(k = 0; k <= m; k += 2) { l = 0; while(l < n/2) { y = l * 4 – x;...
Question 20 Find a theta notation for the number of times the statement x = x + 1 is executed: 12 while i<n) 12 - - 1 02") (1) e(n) edign) On ign) edgign)
4. Big-Oh and Rune time Analysis: describe the worst case running time of the following pseudocode functions in Big-Oh notation in terms of the variable n. howing your work is not required (although showing work may allow some partial t in the case your answer is wrong-don't spend a lot of time showing your work.). You MUST choose your answer from the following (not given in any particular order), each of which could be re-used (could be the answer for...
Let A[1..n] be an array with n elements. Consider the Count-Occurrence algorithm with the pseudocode below. Count-Occurrence(A, n, k). count 0 for j = 1 to n if A[j] ==k count = count+1 print count Which of the following is the correct loop invariant for the for loop? At the start of each iteration jof the for loop, count represents the number of times that k occurs in the subarray A[1.j]. At the start of each iteration of the for...