Answered step by step
Verified Expert Solution
Question
1 Approved Answer
FindMax ( ( a 0 , a 1 , dots, a n - 1 ) ) : largest = a 0 for i = 1
FindMax dots, :
largest
for dots,:
largest :
largest
return largest
Consider the loop invariant:
After iterations, largest is equal to the maximum of dots,
Fill in the blanks of the proof that the loop invariant is correct:
The proof will be by using: induction
Base Case: After iterations of the for loop before the loop begins:
Inductive Hypothesis: Assume that for some with that after iterations, largest is equal to the maximum of Inductive Step: in the th iteration, there are cases:
Case : largest By the induction hypothesis largest is the maximum of
and since largest, is the max of dots, largest
Case : largest By the induction hypothesis largest is the maximum of
and since largest, largest is the max of dots,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started