×
×

# Following are four functions intended to return the value

ISBN: 9781429215107 256

## Solution for problem 22 Chapter 2.3

Mathematical Structures for Computer Science | 7th Edition

• Textbook Solutions
• 2901 Step-by-step solutions solved by professors and subject experts
• Get 24/7 help from StudySoup virtual teaching assistants

Mathematical Structures for Computer Science | 7th Edition

4 5 1 425 Reviews
26
5
Problem 22

Following are four functions intended to return the value a[1] + a[2] + g+ a[n] for n 1 (the sum of the first n entries in an array of integers). For those that do not produce correct results, explain what goes wrong. For those that do produce correct results, do a proof of correctness. a. ArraySumA (integers n, a[1], a[2], , a[n]) Local variables: integers i, j i = 0 j = 0 while i n do i = i + 1 j = j + a[i] end while //j now has the value a[1] + a[2] + g+ a[n] return j end function ArraySumA b. ArraySumB (integers n, a[1], a[2], , a[n]) Local variables: integers i, j i = 1 j = 0 while i n do j = j + a[i] i = i + 1 end while //j now has the value a[1] + a[2] + g+ a[n] return j end function ArraySumB c. ArraySumC (integers n, a[1], a[2], , a[n]) Local variables: integers i, j i = 0 j = 0 while i n do j = j + a[i] i = i + 1 end while //j now has the value a[1] + a[2] + g+ a[n] return j end function ArraySumC

Step-by-Step Solution:
Step 1 of 3

L31 - 7 2) Consider the following formula ▯n n(n +1(2 n +1) 1 +2 + ... + n = i = . i=1 6 Use it to ﬁnd the...

Step 2 of 3

Step 3 of 3

##### ISBN: 9781429215107

Since the solution to 22 from 2.3 chapter was answered, more than 216 students have viewed the full step-by-step answer. This full solution covers the following key subjects: . This expansive textbook survival guide covers 41 chapters, and 1956 solutions. This textbook survival guide was created for the textbook: Mathematical Structures for Computer Science, edition: 7. Mathematical Structures for Computer Science was written by and is associated to the ISBN: 9781429215107. The answer to “Following are four functions intended to return the value a[1] + a[2] + g+ a[n] for n 1 (the sum of the first n entries in an array of integers). For those that do not produce correct results, explain what goes wrong. For those that do produce correct results, do a proof of correctness. a. ArraySumA (integers n, a[1], a[2], , a[n]) Local variables: integers i, j i = 0 j = 0 while i n do i = i + 1 j = j + a[i] end while //j now has the value a[1] + a[2] + g+ a[n] return j end function ArraySumA b. ArraySumB (integers n, a[1], a[2], , a[n]) Local variables: integers i, j i = 1 j = 0 while i n do j = j + a[i] i = i + 1 end while //j now has the value a[1] + a[2] + g+ a[n] return j end function ArraySumB c. ArraySumC (integers n, a[1], a[2], , a[n]) Local variables: integers i, j i = 0 j = 0 while i n do j = j + a[i] i = i + 1 end while //j now has the value a[1] + a[2] + g+ a[n] return j end function ArraySumC” is broken down into a number of easy to follow steps, and 207 words. The full step-by-step solution to problem: 22 from chapter: 2.3 was answered by , our top Math solution expert on 01/18/18, 05:04PM.

#### Related chapters

Unlock Textbook Solution