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
for i := 1 to n for j:=1 to n top:=ij+j+10 a) There are iterations. each iteration contains 2 additions and 1 multiplication. so, total number of operations = f(n) = b) f(n) =
consider this segment of an algorithm: for i := 1 ton n for j:=1 to n...
Give a big-O estimate for the number of additions ued in the segment of an algorithm below. t:=0 for i := 1 to n for j := 1 to n t := t + i + j
) Consider the following algorithm procedure polynomial (c, a0,a1, …, an) power :=1 y≔a0 for i=1 to n power≔power*c y≔y+ai*power return y Find a big-O estimate for the number of additions and multiplications used by this algorithm.
3) [16 points totall Consider the following algorithm: int SillyCalc (int n) { int i; int Num, answer; if (n < 4) 10; return n+ else f SillyCalc(Ln/4) answer Num Num 10 for (i-2; i<=n-1; i++) Num + = answer + answer; answer return answer } Do a worst case analysis of this algorithm, counting additions only (but not loop counter additions) as the basic operation counted, and assuming that n is a power of 2, i.e. that n- 2*...
I need help with my discrete math problem. can you show me step by step process . Thanks in advance 3. Give a big-O estimate and a pair of witnesses for the number additions used in this segment of an algorithm. t:= 0 for i:=1 ton for j := 1 to n-i t:=t+i+j
1, Variation on 3.3#4] Give a big-O estimate in terms of n for the number of oper- ations used in this segment of an algorithm, where an operation is an addition or a multiplication, (ignoring comparisons used to test the conditions in the while loop). while i 〈 n j:= j + i [10 points]
Show that the number of multiplications used in this algorithm is Consider the following algorithm: procedure multiplications(n: positive integer) for i := 1 to n for j:-1 to i t_2.t return t O (n2) 7l
Find Big-O notation for the following algorithm: int function9(int n) { int ij for (i-0; in; i++) for (0; j<n; j++ if (j1) break return j; } int function9(int n) { int ij for (i-0; in; i++) for (0; j
9. (5 points) Please describe an algorithm that takes as input a list of n integers and finds the number of negative integers in the list. 10. (5 points) Please devise an algorithm that finds all modes. (Recall that a list of integers is nondecreasing if each term of the list is at least as large as the preceding term.) 11. (5 points) Please find the least integer n such that f() is 0(3") for each of these functions f()...
procedure polynomial (?,?0,?1,…,??) ?????∶=1 ?≔?0 ??? ?=1 ?? ? ?????≔?????∗? ?≔?+??∗????? ?????? ? Find a big-? estimate for the number of additions and multiplications used by this algorithm.
(b) Consider the following algorithm for (i = n; i >-1; i i/2) for j in range [1, i] Constant Number of Operations Derive the run time of the above algorithm (as a function of n). You must formally derive the run-times (merely stating run times or high level explanation of run time do not suffice)