(String[] args)
| 2 | public class InterpolationSearch { |
| 3 | |
| 4 | public static void main(String[] args) { |
| 5 | Scanner sc = new Scanner(System.in); |
| 6 | int[] arr = {12, 23, 10, 34, 55, 4, 68, 3, 73}; |
| 7 | Arrays.sort(arr); |
| 8 | System.out.println("sorted array- " + Arrays.toString(arr)); |
| 9 | System.out.println("Enter value to search: "); |
| 10 | int searchElement = sc.nextInt(); |
| 11 | int index = interpolationSearch(arr, searchElement); |
| 12 | if(index != -1){ |
| 13 | System.out.println("Searched item " + arr[index] + " found at index "+index); |
| 14 | }else{ |
| 15 | System.out.println("Searched item " + searchElement + " not found in the array"); |
| 16 | } |
| 17 | sc.close(); |
| 18 | } |
| 19 | |
| 20 | private static int interpolationSearch(int[] arr, int searchElement){ |
| 21 | int start = 0; |
nothing calls this directly
no test coverage detected