Searching Problem List

Interpolation Search. Youtube. GFS.  The search works well for uniformly distributed numbers.  Formula Calculation - So the formula to estimate the position = pos = lo + [ (x-arr[lo])*(hi-lo) / (arr[hi]-arr[Lo]) ] arr[] ==> Array where elements need to be searched x ==> Element to be searched lo ==> Starting index in arr[] hi ==>… Continue reading Searching Problem List

Advertisements

Binary Search

Pending - 8, 14, 20, 21, 22, 26, Best case - O (1) comparisons Worst case - O (log n) comparisons Average case - O (log n) comparisons *** Collections.binarySearch() in Java with Examples. *** Arrays.binarySearch() in Java with examples *** How to calculate mid in binary search for larger array.  int mid =(low +… Continue reading Binary Search