Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement