first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* SequentialSearchSortedarray
|
||||
*/
|
||||
public class SequentialSearchSortedarray {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] sortedArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
int index = SeqSearch(sortedArray, 53);
|
||||
if (index != -1) {
|
||||
System.out.println("Element found at index " + index);
|
||||
} else {
|
||||
System.out.println("Element not found");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int SeqSearch(int[] arr, int value) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
if (arr[i] == value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user