Skip to content

Commit 22a6a92

Browse files
authored
bug fixes: comments and package location
1 parent bbdc0f8 commit 22a6a92

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

Diff for: linearSearch.java

-61
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
package Techsparx.Arrays;
2-
31
import java.util.Scanner;
4-
/**
5-
* Write a description of class linearSearch here.
6-
*
7-
* @author (your name)
8-
* @version (a version number or a date)
9-
*/
102
public class linearSearch
113
{
124
public static void main(String args[])
@@ -58,56 +50,3 @@ else if ( flag == false)
5850
}
5951
}
6052
}
61-
62-
/*
63-
public class linearSearch
64-
{
65-
public static void main(String args[])
66-
{
67-
//declaration
68-
Scanner sc = new Scanner(System.in);
69-
int n, position, key, a[];
70-
boolean flag;
71-
72-
//reading the number of array elements
73-
System.out.println("Enter the number of array elements: ");
74-
n = sc.nextInt();
75-
76-
//creating an array of size n
77-
a = new int[n];
78-
79-
//reading the array elements
80-
System.out.println("Enter " + n + " array elements");
81-
for(int i = 0 ; i < n ; i++)
82-
{
83-
a[i] = sc.nextInt();
84-
}
85-
86-
//reading the array element to be found/searched
87-
System.out.println("Enter th number to be found: ");
88-
key = sc.nextInt();
89-
90-
//Linear search
91-
flag = false ; position = 0 ;
92-
for(int i = 0 ; i < n ; i++)
93-
{
94-
if(key == a[i])
95-
{
96-
flag = true;
97-
position = i+1;
98-
break;
99-
}
100-
}
101-
102-
//chccking flag
103-
if(flag == true)
104-
{
105-
System.out.println(key + " is found at position: " + position);
106-
}
107-
else
108-
{
109-
System.out.println(key + " is NOT found ");
110-
}
111-
}
112-
}
113-
*/

0 commit comments

Comments
 (0)