Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int search(char * s1, char ** s2, int dictSize){
- printf("in bin search \n");
- printf("%s\n",s1);
- int first, last, middle;
- first = 0;
- last = dictSize - 1;
- middle = (first + last)/2;
- int res = strcmpIgnoreCase(s1, s2[middle]);
- while(first <= last)
- {
- if(res == 0) {
- //printf("Correctly spelled");
- printf("The value of middle is ");
- printf("%d", middle);
- return 0;
- }
- else if(res >= 0) {
- //printf("testing7");
- first = middle + 1;
- //middle = (first + last)/2;
- }
- else{
- //printf("testing8");
- last = middle - 1;
- //middle = (first + last)/2;
- }
- middle = (first + last)/2;
- printf("The value of res is ");
- printf("%d",res);
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement