DISCRETE MATH A function receives a positive integer m as the input and returns
ID: 3786773 • Letter: D
Question
DISCRETE MATH
A function receives a positive integer m as the input and returns the value Compute (n) = sigma_j = 1^n(j + 2)j^2. Fill in the blanks for recursive algorithm to compute the sum given above. The value returned should be a mathematical expression that uses variables y and/or n and only uses addition or multiplication operations. There should be no summation notation in your responses. Compute Sum (n) If (_____)Return (_____)//Base case y: = Compute Sum (_____)//Recursive Call Return(_____) End The function below receives two inputs: a and n, where a is a real number and n is a non-negative integer. The algorithm returns a times n. Product (a, n) If(n = 0) Return (0) y: Product(a, n -1) Return (a + y) End Let NUMADD(a, n) be the number of addition operations performed by the algorithm Product on inputs a and n. What is NUMADD(a, 0)? Express NUMADD (a, k + 1) is a function of NUMADD (a, k).Explanation / Answer
8)
computeSum(n)
if (n==1) return 3; //(1+2)*1*1 // (j+2)*j*j
y = computeSum(n-1)
return (y+((n+2)*n*n))
end
9)
a) zero
explanation : zero times a is a, no need to perform any addition
b)
NumADD(a,k+1) = NumADD(a,k)+1
explanation:
NumADD(a,n) returns the number of addition operations required by algorithm Product
in Product algorithm, n times a, means, a added to itself n times... so.. 'n' addition operations needed
hence NumADD(a,n) returns 'n'..
NumADD(a,k+1) should return k+1 (addition operations)
NumADD(a,k) should return k
so..
NumADD(a,k+1) = NumADD(a,k)+1
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.