ErliPan

Untitled

Jan 11th, 2021
537
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool binarySearch(struct list ** ptr,int search, int size) {
  2.  
  3.     if (size > 0) {
  4.         struct list **meta = ptr;
  5.         for (int i = 0;i < size / 2;i++)
  6.             meta = &(*meta)->next;
  7.  
  8.         if (search == (*meta)->value) return true;
  9.  
  10.         if (search < (*meta)->value) {
  11.             return binarySearch(ptr, search, size/2);
  12.         } else {
  13.             return binarySearch(meta, search, size - (size/2));
  14.         }
  15.  
  16.     }
  17.     return false;
  18. }
RAW Paste Data