Question: In Java Please Create a sorted list of 1 0 integers, then create a binary search algorithm that searches through that sorted list. Print out
In Java Please
Create a sorted list of integers, then create a binary search algorithm that searches through
that sorted "list". Print out the target element and the number of elements checked before the
target element was found. If the element was not found in the list, print an appropriate message.
Hint: to keep track of the number of elements checked before the targe element is found, create a
global variable and increment it each time an element is checked and print it in the main method.
Now update your program so that it implements an Interpolation Search method. Interpolation
search is similar to binary search, except it tries to begin the search nearer to the location of the
target element. Instead of the using the middle value of the sorted array, interpolation search
estimates the location of the target with respect to the first & last values in the array. The
implementation is the same as binary search except that you should calculate the mid value as:
mid first last first
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
