Can I please have an explanation for where the numbers "2" and "3" come from?
We want the number of multiplications performed.
Outer For
Loop
weirdSum = weirdSum * 5 - i * 2;
In the above line 2 multiplications are performed
1. weirdSum * 5
2. i * 2
Inner For
Loop
weirdSum = weirdSum * n - j * 3 + i * j;
In the above line 3 multiplications are performed
1. weirdSum * n
2. j * 3
3. i * j
Can I please have an explanation for where the numbers "2" and "3" come from? (b)...
(1) Give a formula for SUM{i} [i changes from i=a to i=n], where a is an integer between 1 and n. (2) Suppose Algorithm-1 does f(n) = n**2 + 4n steps in the worst case, and Algorithm-2 does g(n) = 29n + 3 steps in the worst case, for inputs of size n. For what input sizes is Algorithm-1 faster than Algorithm-2 (in the worst case)? (3) Prove or disprove: SUM{i**2} [where i changes from i=1 to i=n] ϵ tetha(n**2)....
HOW DOES THE CODE WORK AND PLEASE TELL ME WHERE DID THE NUMBER [J] COME FROM WHEN IT HASN'T BEEN DECLARED IN THE ABOVE STATEMENT MOREOVER KINDLY ALSO DRY RUN THE PROGRAM TO MAKE IT MUCH EASIER TO UNDERSTAND int main() { int i, j, a, n, number[i]; printf("Enter the value of N \n"); scanf("%d", &n); printf("Enter the numbers \n"); for (i = 0; i < n; i++) scanf("%d", &number[i]); for (i = 0; i < n; ++i) { for...
4. [16 marks total (6 marks each)] Do a worst-case analysis for the following algorithm segments, counting the number of multiplications which occur. I have marked the lines with the multiplications you are to count with ). For all of these algorithms, use n as your fixed input size (even though n doesn't really represent the "size" of the input). Be sure to include an explanation with your answers to obtain full marks. (a) t-10; for (i-1;in-H) t-5*t; (b) (For...
I don’t understand can you help 5. Given the definition and code fragment: (2 points int matrix[2]13]; int k = 0; for(int i =0; i < 2; i++) for (int j=0, j < 3 ) matrix[i]lj]-k++; The value of matrix[1][1] is
Please let me know if you have any questions. Thanks in advance! We want to develop a code that calculates In(1 - x) =- on the interval -1<x<1. First, understand what this notation represents. The capital sigma (2) indicates that a summation of terms is to be performed. (The term summation still applies even though all the terms are negative.) We are also given the prototype term written in terms of x and n. The notation also tells us that...
8. R-4.8 Order the following functions by asymptotic growth rate. 4nlogn + 2n 2^10 2^logn 3n + 100logn 4n 2^n n^2 + 10n n^3 nlogn 9. R-4.9 Give a big-Oh characterization, in terms of n, of the running time of the example 1 method shown in Code Fragment 4.12. 10. R-4.10 Give a big-Oh characterization, in terms of n, of the running time of the example 2 method shown in Code Fragment 4.12. 11. R-4.11 Give a big-Oh characterization, in...
Please give explanation as well ma E. Asymptotic Analysis rays For these problems, you should give a brief explanation as hws.txt. You should not use any fancy typesetting tools (like LaTeX, Word, etc.). Just submit a text file called hws.txt. You are not required to explain your solutions, but you are encouraged to do so. Provide simple and tight asymptotic bounds for each of the following. Here, "simple" means roughly "no unnecessary terms or constants' and "tight" means "either the...
Summation Homework 1 Summation Homework From the following program fragment given below: 2-1 sumo for to n-1 do for je to do for k0 to j-1 do sum sum + 1 end-for end-for end-for write sum derive function sum(n) in a closed form such that: (a) Values of sum(n) for any given n are exactly the same as the values of variable sum in the program above. (b) All sums resulting from your analysis are derived based on what was...
Can I please have a detailed explanation of Question a and c only ( Please clear handwriting ) Question 1 (no working required in parts (a) and (b)) (a) Consider the following formulae for a volume V in terms of lengths x and Other qu antities are dimensionless : Write down which one of the above is not dimensionally homogeneous b) Write down which one of the following is in units of pressure: (A) J m-2 (B) Pa m-2 (C)...
Can i get the answers for 1,2,3 and 4 1. What are the values of int x in the following C++ statement? 2 each a) x = 18 % 5; b)x= (4/5)==0.8; c)X =( 4 - 3 * 2 == 2) ?0:1; 2. What will x and y be when each part starts out with integers x = 6, y = -4 and z=5? 2 each a) x *= 12 - x; x becomes b) z= x++ + x; x...