Question: The following find _ min function should return the smallest integer from a given array A . func find _ min ( A [ ]

The following find_min function should return the smallest integer from a given array A.
func find _min (A []int) int {
var result int =0;
for i :=1; i< len(A); i++(
if result >A[i]{
result = A[i];
}
}
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, i.e., an array A consisting of N integers such that find_min retuns the wrong answer. Write a function:
func Solution(N int)[]int
that, given an integer N, returns an array A consisting of N integers which describes a counterexample.
Example:
Given N=4 your function may return [4,2,4,5]. It is a counterexample, because calling the find_min function with this array returns 0, but the correct answer is 2. Your function may also return another counterexample; for example [10,567,99,456].
Assume that:
N is an integer within the range [1,....,1000]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!