Search Element
Search Element — refers to the process of finding a specific value within an array data structure.
public static int linearSearch(int[] array, int target) {
for (int i = 0; i < array.length; i++) {
if (array[i] == target) {
return i; // Return index if found
}
}
return -1; // Return -1 if not found
} To search element in an array, we can use the linear search algorithm.
Search Element → belongs to → Array Algorithms.
Semantic portal