Grokking Java Basics
0% completed
Linear Search
Linear Search is one of the simplest searching algorithms. It sequentially checks each element of a list until the desired element is found or the list ends.
Problem Statement
Write a Java program to perform a linear search on an array of integers. The program should search for a specific target value and return the index of the target if found. If the target is not present in the array, the program should indicate that the target is not found.
Example:
- Input:
- Array:
[4, 2, 7, 1, 3] - Target:
7
- Array:
- Output: Target 7 found at index 2.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%