Please post proof rules used if proof is correct Following a
Please post proof rules used if proof is correct.
Following are four functions intended to return the a12] a[n] for n 1 (the sum of the first n in an array value a[1] produce correct results, goes wrong. entries of integers). For those that do not explain what For those that do produce correct results, do proof of correctness.Solution
No,the proof is not correct. Thare are two mistakes in the program ;first is the condition in while loop. It should be while i<n as the range of the index of array starts from 0 - (n-1) . So, if we use the given condition then array out of bounds error will be generated. And , second mistake is value of i . As per question ,it says sum of first entries in the array ; theoretically first element of array is array[1] but practically it is stored in computer as array[0] therefore the range of index of array is 0 - (n-1)
![Please post proof rules used if proof is correct. Following are four functions intended to return the a12] a[n] for n 1 (the sum of the first n in an array valu Please post proof rules used if proof is correct. Following are four functions intended to return the a12] a[n] for n 1 (the sum of the first n in an array valu](/WebImages/33/please-post-proof-rules-used-if-proof-is-correct-following-a-1096115-1761578043-0.webp)