Created
June 30, 2012 18:49
-
-
Save obstschale/3025082 to your computer and use it in GitHub Desktop.
Linear Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int linearSearch(char *list[ ], char target[ ], int n) | |
{ | |
int i; | |
for (i = 0; i < n; i++) | |
{ | |
if (strcmp(target, list[i]) == 0) | |
{ | |
return i; | |
} | |
} // end for | |
return -1; | |
} // end linear search |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
returns index of target string in the given list,
Or returns -1 if target string is not found.