Advertisement
ahmed19981973

Untitled

Feb 6th, 2019
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.56 KB | None | 0 0
  1.   public static<T extends Comparable<T>> int search (T key,List<T> pl,int bottom,int top ){
  2.         int  middle ;
  3.         if (top>=bottom){
  4.             middle=  (top+bottom)/2;
  5.             if (key==(pl.retreiveList(middle)))
  6.                 return middle;
  7.             if (key.compareTo(pl.retreiveList(middle))<0){
  8.                 search(key,pl,bottom,middle-1);
  9.                 return  search(key,pl,bottom,middle-1);
  10.             }
  11.             else
  12.                 return search(key, pl, middle + 1, top) ;
  13.            
  14.         }
  15.         return -1;
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement