Skip to content

Commit 191a268

Browse files
committed
Add LinearSearchRecursive.java and update README.md
1 parent 3ca4ba8 commit 191a268

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ In order to achieve greater coverage and encourage more people to contribute to
367367
</a>
368368
</td>
369369
<td> <!-- Java -->
370-
<a href="./CONTRIBUTING.md">
371-
<img align="center" height="25" src="./logos/github.svg" />
370+
<a href="./src/java/LinearSearchRecursive.java.md">
371+
<img align="center" height="25" src="./logos/java.svg" />
372372
</a>
373373
</td>
374374
<td> <!-- Python -->

src/java/LinearSearchRecursive.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class LinearSearchRecursive {
2+
public static void main(String[] args) {
3+
int[] arr = {10,20,50,60,30,60,70,80,22,56,2,7,9,0,44};
4+
System.out.println(LinearRecursive(arr, 0, 9));
5+
System.out.println(LinearRecursive(arr, 0, 45));
6+
}
7+
8+
public static int LinearRecursive(int[] arr, int i, int key){
9+
10+
if(i<arr.length){
11+
if(arr[i] == key) return i;
12+
else return LinearRecursive(arr, i+1, key);
13+
}
14+
15+
return -1;
16+
}
17+
}

0 commit comments

Comments
 (0)