From 569c71f8f2c0be70d381b149f60e0a868ea1150b Mon Sep 17 00:00:00 2001 From: Mayank Kinger Date: Sat, 6 Oct 2018 20:58:01 +0530 Subject: [PATCH 1/2] Added Java-LinearSearch-10 --- README.md | 1 + java-linear-search/Java-LinearSearch-10.java | 16 ++++++ java-linear-search/java-linear-serach-3.java | 50 ++++--------------- .../javascript-Linear-Search-2.js | 28 +++++++++-- 4 files changed, 50 insertions(+), 45 deletions(-) create mode 100644 java-linear-search/Java-LinearSearch-10.java diff --git a/README.md b/README.md index cfe0fb0..775fa0c 100644 --- a/README.md +++ b/README.md @@ -33,3 +33,4 @@ Linear search is a very simple search algorithm. In this type of search, a seque |20| [Marco Wang](https://github.com/aesophor) | University of Taipei | Taiwan | Java, C, Bash, Python-3 | |21| [Grzegorz Wcisło](https://github.com/grzegorz-wcislo) | | Poland | | |22| [Ivan Dyominov](https://github.com/dyominov) | | Ukraine | Scala | +|23| [Mayank](https://github.com/dyominov) | | India | Java | diff --git a/java-linear-search/Java-LinearSearch-10.java b/java-linear-search/Java-LinearSearch-10.java new file mode 100644 index 0000000..9756bab --- /dev/null +++ b/java-linear-search/Java-LinearSearch-10.java @@ -0,0 +1,16 @@ +public class LinearSearch { + public static void main(String args[]){ + int array[] = {10, 20, 25, 63, 96, 57}; + int size = array.length; + int value = 63; + + for (int i=0 ;i< size-1; i++){ + if(array[i]==value){ + System.out.println("Element found index is :"+ i); + }else{ + System.out.println("Element not found"); + } + } + } +} + diff --git a/java-linear-search/java-linear-serach-3.java b/java-linear-search/java-linear-serach-3.java index db92bfe..acb0804 100644 --- a/java-linear-search/java-linear-serach-3.java +++ b/java-linear-search/java-linear-serach-3.java @@ -1,47 +1,15 @@ -import java.util.Scanner; -import java.util.Random; -import java.util.Arrays; - -/** - * Implements the linear search algorithm in Java. - * Created on 2018/09/30 by Craxy. - * - * @author Craxy - * @version 1.1 - */ public class LinearSearch { + public static void main(String args[]){ + int array[] = {10, 20, 25, 63, 96, 57}; + int size = array.length; + int value = 63; - /** - * The entry point for the program. - * - * @param args the command line arguments. - */ - public static void main(String[] args) { - System.out.println("How many number are you going to enter? "); - Random rand = new Random() - //Create the scanner instance and the array of numbers - Scanner scanner = new Scanner(System.in); - int len = scanner.nextInt(); - int[] array = new int[len]; - - for(int x=0; x Date: Sat, 6 Oct 2018 20:59:51 +0530 Subject: [PATCH 2/2] Updated my contribution in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 775fa0c..9effe73 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ Linear search is a very simple search algorithm. In this type of search, a seque |20| [Marco Wang](https://github.com/aesophor) | University of Taipei | Taiwan | Java, C, Bash, Python-3 | |21| [Grzegorz Wcisło](https://github.com/grzegorz-wcislo) | | Poland | | |22| [Ivan Dyominov](https://github.com/dyominov) | | Ukraine | Scala | -|23| [Mayank](https://github.com/dyominov) | | India | Java | +|23| [Mayank Kinger](https://github.com/kingermayank) | | India | Java |