SHARE
TWEET

Untitled

a guest Mar 21st, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool lookup(string s) { // TODO int start = 0; int end = dictionary.size;
  2.  
  3. while (start <= end)
  4. {
  5.     int mid = (start + end) / 2;
  6.  
  7.     if (strcmp(s, dictionary.words[mid].letters) == 0)
  8.     {
  9.         dictionary.words[mid].found = true;
  10.         return true;
  11.     }
  12.     if (strcmp(s, dictionary.words[mid].letters) < 0)
  13.     {
  14.         end = mid - 1;
  15.     }
  16.     if (strcmp(s, dictionary.words[mid].letters) > 0)
  17.     {
  18.         start = mid + 1;
  19.     }
  20. }
  21. return false;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top