Problem:
Write a methoe that binary search an array using Comparable in Java.
Output:
Not applicable.
Solution:
public static int binarysearch(Comparable[] items, Comparable target, int first, int last) { if(first>last) return -1; else { int middle=(first+last)/2; int value=target.compareTo(items[middle]); if(value==0) return middle; else if(value>0) return binarysearch( items, target, middle+1, last); else return binarysearch( items, target, first , middle-1); }
tumescent liposuction Korea's #1 Liposculpture Clinic. Lydian plastic surgery is the home of VIP patients. Celebrities, Influencers and Diplomats all know and trust Doctor An and Lydian plastic surgery clinic to provide detailed results.
ReplyDelete