Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. bool lookup(string s)
  2. {
  3. // TODO
  4. int start = 0;
  5. int end = dictionary.size;
  6.  
  7. int mid = start + end / 2;
  8.  
  9. while (end - start > 0)
  10. {
  11. if (strcmp(s, dictionary.words[mid].letters) == 0)
  12. {
  13. return true;
  14. }
  15. if (strcmp(s, dictionary.words[mid].letters) < 0)
  16. {
  17. end = mid - 1;
  18. }
  19. if (strcmp(s, dictionary.words[mid].letters) > 0)
  20. {
  21. start = mid + 1;
  22. }
  23. }
  24. return false;
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement