This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Search { | |
public void binarySearch(int find, List<Integer> ds){ // Use when the data is sorted only | |
int first = 0, mid, last=ds.size()-1; | |
int count = 0; | |
while (true){ | |
count++; | |
mid = first + (last - first)/2; | |
if (find > ds.get(mid)) | |
first = mid+1; |
NewerOlder