Skip to content

Instantly share code, notes, and snippets.

@ammardev
ammardev / Java search class
Created February 19, 2017 12:16
Not Complete
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;