Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int search(List first,int key, int low, int high){
- int pivot;
- if(low <= high){
- pivot = (low + high) / 2;
- first.moveCursor(pivot);
- if(first.getCursor() == key){
- return pivot;
- }else if(key < first.getCursor()){
- return search(first, key, low, pivot-1);
- }else if(key > first.getCursor()){
- return search(first, key, pivot+1, high);
- }
- }
- else{
- return -1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement