Question: The following find _ min function should return the smallest integer from a given array A . func find _ min ( A [ ]
The following findmin function should return the smallest integer from a given array A
func find min A int int
var result int ;
for i :; i lenA; i
if result Ai
result Ai;
return result;
;
Unfortunately it is an incorrect implementation. In other words, when the function is called with certain paramaters, it returns the wrong answer. Your task is to generate a counterexample, ie an array A consisting of N integers such that findmin retuns the wrong answer. Write a function:
func SolutionN intint
that, given an integer N returns an array A consisting of N integers which describes a counterexample.
Example:
Given N your function may return It is a counterexample, because calling the findmin function with this array returns but the correct answer is Your function may also return another counterexample; for example
Assume that:
N is an integer within the range
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
