Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update LinearSearchThread.java
  • Loading branch information
yanglbme authored Nov 26, 2021
commit 1a645046444c851852070f2b1fcd3b705fd90737
23 changes: 11 additions & 12 deletions src/main/java/com/thealgorithms/searches/LinearSearchThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.Scanner;

class LinearSearchThread {
public class LinearSearchThread {
public static void main(String[] args) {
int[] list = new int[200];
for (int j = 0; j < list.length; j++) {
Expand Down Expand Up @@ -36,27 +36,26 @@ public static void main(String[] args) {
}

class Searcher extends Thread {
private int[] f;
private int a, b;
private int x;
private final int[] arr;
private final int left, right;
private final int x;
private boolean found;

Searcher(int[] f, int a, int b, int x) {
this.f = f;
this.a = a;
this.b = b;
Searcher(int[] arr, int left, int right, int x) {
this.arr = arr;
this.left = left;
this.right = right;
this.x = x;
}

@Override
public void run() {
int k = a;
int k = left;
found = false;
while (k < b && !found) {
if (f[k] == x) {
while (k < right && !found) {
if (arr[k++] == x) {
found = true;
}
k++;
}
}

Expand Down