Complete the code to start the linear search loop from the first index.
for (int i = [1]; i < arr.length; i++) { if (arr[i] == target) { return i; } }
The linear search starts checking from the first element, which is at index 0.
Complete the code to return -1 if the target is not found after the loop.
for (int i = 0; i < arr.length; i++) { if (arr[i] == target) { return i; } } return [1];
Returning -1 indicates the target was not found in the array.
Fix the error in the condition to correctly compare array element with target.
if (arr[i] [1] target) { return i; }
Use '==' to compare values for equality in Java, not '=' which is assignment.
Fill both blanks to create a linear search method header and return type.
public static [1] linearSearch(int[] arr, int target) { for (int i = 0; i < arr.length; i++) { if (arr[i] == target) { return i; } } return -1; }
The method returns the index of the target, which is an integer.
Fill all three blanks to complete the linear search method with correct parameter names and return statement.
public static int linearSearch([1][] [2], int [3]) { for (int i = 0; i < [2].length; i++) { if ([2][i] == [3]) { return i; } } return -1; }
The method takes an integer array named 'arr' and an integer 'target' to search for.
