Skip to content
This repository has been archived by the owner on Dec 29, 2019. It is now read-only.

Commit

Permalink
Merge pull request #9 from josephshawcroft/master
Browse files Browse the repository at this point in the history
Implemented LinearSearch java
  • Loading branch information
ayan-b authored Apr 23, 2018
2 parents 3feaa6a + cafdfe2 commit 23119cc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LinearSearch.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
public class LinearSearch {

public static void main(String[] args) {
int myList[] = {1,2,3,8,9,12};
int key = 2;

String output = linearSearch(myList, key) ? "Successful Search" : "Unsuccessful Search";
System.out.println(output);

}

private static boolean linearSearch(int[] list, int key) {

for(int i = 0; i < list.length; i++) {
if(list[i] == key){
return true;
}

}
return false;
}
}

public static int linearSearch(int[] arr, int key){

Expand Down

0 comments on commit 23119cc

Please sign in to comment.