Question: Consider the problem of finding the closest integer to a test integer in an array of N positive integers. For example, in the array [23,

Consider the problem of finding the closest integer to a "test integer" in an array of N positive integers. For example, in the array [23, 12, 78, 45, 56, 46, 33, 25], the closest integer to "50" is 46. Brute Force Approach: A brute force approach to determine the closest integer to a test integer would be to scan through the array and determine the absolute value of the difference between the test integer and each of the integers in the array. We keep track of the minimum absolute difference found so far and the corresponding integer in the array. After scanning through the entire array, we can print the corresponding integer that has the minimum absolute difference with the test integer. Example for the Brute Force Approach (test integer: 50") 23, 12, 78, 45, 56, 46, 33, 25] 27 38 28 5 6 4 17 25 Array Abs. Diff with "50 Min. Abs Diff with "50%127 2727 5 5 4 4 4 Estimate of the Closest Integer23 23 23 45 45 46 46 46 Question 1: What is the asymptotic time complexity (with respect to the number of comparisons) of the brute force approach described above? Justify your
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
