From cf8527eb50f5e48605281bf5b8980eb8602ab074 Mon Sep 17 00:00:00 2001 From: MohitBehl Date: Sat, 12 Oct 2019 15:23:01 +0530 Subject: [PATCH] Created LinearSearch.java --- LinearSearch.java | 46 ++++++++++++++++++++++++++++++++++++---------- linearSearch.md | 21 +++++++++++++++++++++ 2 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 linearSearch.md 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