MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / main

Method main

Programs/InterpolationSearch.java:4–18  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

2public 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;

Callers

nothing calls this directly

Calls 3

interpolationSearchMethod · 0.95
toStringMethod · 0.80
sortMethod · 0.45

Tested by

no test coverage detected