subject

Consider the following program specification: input: an integer n > 0 and an array - 1)] of n integers. output: the largest index s such that a[s] is the smallest value in - 1)].for example, if n = 10 and a = [ 4, 8, 1, 3, 1, 5, 4, 7, 1, 2 ] (so a[0] = 4, a[1] = 8, then the program would return 8, since the smallest value in a is 1 and the largest index at which 1 appears is index 8.consider the following implementation: indexofmin(n, a)(1) i ← 1(2) m ← a[0](3) s ← 0(4) while i < n(5) if a[i] ≤ m then(6) m ← a[i](7) s ← i(8) end(9) i ← i + 1(10) end(11) return s
in the implementation above, line numbers are given so you can refer to specific lines in your answers and ← is used to indicate assignment. part a (18 points)use induction to establish the following loop invariant right before the while test in line (4) is executed: 0< i ≤ nm = a[s]m = min a[0 .. (i - 1)] (i. e., m is the minimum value in that appears in the array a between indices 0 and i - 1, inclusive)s is the largest index at which min a[0 .. (i - 1)] appears
hints and tips: use only one induction proof and prove each of the four parts of the invariant in your base case and inductive step. you may assume that i and s will always be integers (i. e., you don't have to prove this).part b (7 points)prove the correctness of the implementation by arguing partial correctness and termination.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:00
Laire writes a letter to her grandmother, in which she describes an amusement park she visited last week. she adds pictures of that place in her letter. which feature of a word processing program will claire to remove unwanted parts of the pictures?
Answers: 3
question
Computers and Technology, 23.06.2019 16:30
How to do this programming flowchart?
Answers: 3
question
Computers and Technology, 24.06.2019 14:00
In simple terms, how would you define a protocol?
Answers: 2
question
Computers and Technology, 25.06.2019 16:00
Which function would you use to make sure all names are prepared for a mailing label?
Answers: 2
You know the right answer?
Consider the following program specification: input: an integer n > 0 and an array - 1)] of n...
Questions
question
History, 27.11.2019 19:31
question
History, 27.11.2019 19:31
question
English, 27.11.2019 19:31
question
Mathematics, 27.11.2019 19:31
Questions on the website: 13722361