Skip to content

Commit

Permalink
Update Linear_search.java
Browse files Browse the repository at this point in the history
  • Loading branch information
MSufiyanAG authored Jun 28, 2020
1 parent e48e2fb commit b0814f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Java/Linear_search.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
public class Linear_search{
//It iterates through the array to find key .The average time complexity O(n).
static int linsearch(int[] a,int k){
for(int i=0;i<a.length;i++){
if(a[i]==k)
Expand All @@ -11,4 +12,8 @@ public static void main(String[] args){
int key=8;
System.out.println(linsearch(a,key));
}
}
}
/*
output:
3
*/

0 comments on commit b0814f0

Please sign in to comment.