Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. int search(char * s1, char ** s2, int dictSize){
  2. printf("in bin search \n");
  3. printf("%s\n",s1);
  4. int first, last, middle;
  5. first = 0;
  6. last = dictSize - 1;
  7. middle = (first + last)/2;
  8. int res = strcmpIgnoreCase(s1, s2[middle]);
  9.  
  10. while(first <= last)
  11. {
  12.  
  13. if(res == 0) {
  14. //printf("Correctly spelled");
  15. printf("The value of middle is ");
  16. printf("%d", middle);
  17. return 0;
  18.  
  19. }
  20.  
  21. else if(res >= 0) {
  22. //printf("testing7");
  23. first = middle + 1;
  24. //middle = (first + last)/2;
  25.  
  26. }
  27. else{
  28. //printf("testing8");
  29.  
  30. last = middle - 1;
  31. //middle = (first + last)/2;
  32.  
  33. }
  34. middle = (first + last)/2;
  35.  
  36. printf("The value of res is ");
  37. printf("%d",res);
  38. }
  39.  
  40.  
  41.  
  42. return -1;
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement