Linear Search Java Program

preview_player
Показать описание
#techlearners #java #searching

1. Sequential Search or Linear Search
In this, the list or array is traversed sequentially
and every element is checked. For example: Linear Search.
2. Interval Search
These algorithms are specifically designed for searching in
sorted data-structures. These type of searching algorithms
are much more efficient than Linear Search as they repeatedly
target the center of the search structure and divide the
search space in half. For Example: Binary Search.

Some Example search algorithms are
1. Linear Search
2. Binary Search
3. Jump Search
4. Interpolation Search
5. Exponential Search
6. Sublist Search (Search a linked list in another list)
7. Fibonacci Search

Linear Search
linear search or sequential search is a method for finding
a target value within a list. It sequentially checks each
element of the list for the target value until a match is
found or until all the elements have been searched.

List 5 10 6 9 23
Element to be searched 6

Comparison
1. 5 10 6 9 23
6 false
2. 5 10 6 9 23
6 false
3. 5 10 6 9 23
6 true

Logic
store number of elements in size
Input elements in array a[]
Input element to be searched in n
loop for i = 0 to i less then size
if n == a[i]
display "element found"
break

Time Complexity
O(N)

TECHLEARNERS BY NEERAJ SAXENA
Рекомендации по теме