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 02:00
What is the main benefit of minimizing the ribbon in word? more options will be accessible through customized keystrokes. more of the document will be viewable without needing to scroll. fewer controls will be accessible to the user by using the mouse. fewer editing options will be available without entering a password.
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Afiling system in which an intermediary source of reference, such as a file card, must be consulted to locate specific files is called a(n) system. a. shelf filing b. direct filing c. indirect filing d. shingling
Answers: 1
question
Computers and Technology, 24.06.2019 14:00
When creating a field in a table, you must set the to determine what type of data the field can store. field property data type field type data property
Answers: 1
You know the right answer?
Consider the following program specification: input: an integer n > 0 and an array - 1)] of n...
Questions
question
Mathematics, 25.06.2019 05:30