diff --git a/LinearSearch.java b/LinearSearch.java index 671553c..2cb504c 100644 --- a/LinearSearch.java +++ b/LinearSearch.java @@ -1,15 +1,41 @@ +/* + SAMPLE OUTPUT(of the following code): + Element found at index 5 +*/ public class LinearSearch { + //linearSearch() returns index of array if element is found else "-1" if element can't be found in array + + static int linearSearch(int arr[],int ele){ + + int numberOfElements = arr.length; + + for(int index=0;index