I need help with c and d and problem 2 not sure how to do only those methods lll
ID: 1720120 • Letter: I
Question
I need help with c and d and problem 2 not sure how to do only those
methods lll a) For any integer r, If r r 0 then r -1. ms b) For any integer r, If r3 1 is even, then r is odd mi d) If r 4r4 3r3 r2 3r 4 0, then r 0 Problem 2. (20 points) Assume a simplified version of project 1 where grades for each assignment are stored in an one dimensional array. Use (i) induction and (ii) proof by con tradiction to prove the correctness of the following C function which finds the maximum grade in the given array of n elements. Show the induction steps 1 float find-max (float arr, int n float max arr 3 for (int i 0; i n i++)f if arr i) max max (arr i return max; Problem 3. 10 points each) Use induction to prove the following:Explanation / Answer
c) gcd of 21 and 30 is 3 >1
3 doesn't divide 1. 3 divides left hand side
So there can not be any such integers a and b
d) if x <0 then all the terms are negative
Hence their sum (left hand side) < 0
So x>=0 if it is >0
problem 2
by induction ;
if n =1
max = *arr the first element of array
So true for n=1
hypothesis true for n<= m
for n=m+1
if m+1 th element is the max of all element then it is checked and max is updated in the last iteration. otherwise the max of first m elements = max of m+1 elements.
Hence proved for n=m+1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.