Skip to content

Commit ece0ee1

Browse files
committed
Add Linear Search in C
1 parent d0af94c commit ece0ee1

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

LinearSearch/C/LinearSearch.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include "stdlib.h"
2+
3+
int LinearSearch(int *array, int len, int key){
4+
int i;
5+
6+
if(array == NULL){
7+
return -1;
8+
}
9+
10+
for(i = 0; i < len; i++){
11+
if(array[i] == key){
12+
return i;
13+
}
14+
}
15+
16+
return -1;
17+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Inverse Fast Fourier Transform | | | | | :+1: | | | |
3535
Johnson algorithm | :+1: | :+1: | | | :+1: | | | |
3636
Kadane's algorithm | :+1: | :+1: | | | :+1: | :+1: | :+1: | |
3737
Knuth Morris Prath Algorithm | :+1: | :+1: | | | :+1: | | | |
38-
LinearSearch | :+1: | :+1: | | | :+1: | :+1: | | | | |
38+
LinearSearch | :+1: | :+1: | | :+1: | :+1: | :+1: | | | | |
3939
Longest-Common-Subsequence | :+1: | :+1: | | | :+1: | | | | :+1:
4040
Longest-Increasing-Subsequence | :+1: | | | | :+1: | | | |
4141
LongestPath | | | | | :+1: | | | |

0 commit comments

Comments
 (0)