Advertisement
Victorman5

binarySearchIndexOfMinGreaterElement

May 19th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. public static int binarySearchIndexOfMinGreaterElement(double[] list, double value) {
  2.         int left = -1;
  3.         int right = list.length;
  4.  
  5.         int middle;
  6.         while (left < right - 1) {
  7.             middle = (right + left) / 2;
  8.  
  9.             if (list[middle] < value) {
  10.                 left = middle;
  11.             } else {
  12.                 right = middle;
  13.             }
  14.         }
  15.  
  16.         return right;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement