Question: write a java program Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate

write a java program Given an array of sorted integers. We need to find the closest value to the given number. Array may contain duplicate values and negative numbers.
Example - Input :arr[]={2,5,6,7,8,8,9}; Target number =4 Output : 5
Target number =3 Output : 2

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!