Embed presentation
Downloaded 19 times


![WHAT IS A LINEAR SEARCH?
A linear search is a sequential search that
sequentially search a target element in a
list or an array.
Elements may be sorted or unsorted.
The target element is compared with each
element in the list or array and stops
when either the value is found or the end
of array is encountered.
[1][2]](https://image.slidesharecdn.com/daa-180614051411/75/LINEAR-SEARCH-3-2048.jpg)




![ALGORITHM
Linear(a,n,ITEM,LOC)
1. Set a[n+1]:=ITEM.
2. Set LOC:=1.
3. Repeat while a[LOC] != ITEM:
Set LOC:=LOC + 1.
[End of loop.]
4. If LOC = n+1,
then Set LOC:=0. [Unsuccessful]
5. Exit.
[3]](https://image.slidesharecdn.com/daa-180614051411/75/LINEAR-SEARCH-8-2048.jpg)
![COMPLEXITY [1]
CASES
TIME
COMPLEXITY
Best
Average
Worst
O(1)
O(n)
O(n)
1
(n+1)/2
n
F(n)
(COMPARISION)](https://image.slidesharecdn.com/daa-180614051411/75/LINEAR-SEARCH-9-2048.jpg)

The document describes linear search, which sequentially searches through an unsorted array or list to find a target element. It provides an example of searching for the element 68 in an array of numbers. The algorithm increments through each element, comparing it to the target, until either a match is found or the end is reached. The time complexity is O(1) in the best case if the target is first, O(n) on average as it must check half the elements on average, and O(n) in the worst case if the target is last.


![WHAT IS A LINEAR SEARCH?
A linear search is a sequential search that
sequentially search a target element in a
list or an array.
Elements may be sorted or unsorted.
The target element is compared with each
element in the list or array and stops
when either the value is found or the end
of array is encountered.
[1][2]](https://image.slidesharecdn.com/daa-180614051411/75/LINEAR-SEARCH-3-2048.jpg)




![ALGORITHM
Linear(a,n,ITEM,LOC)
1. Set a[n+1]:=ITEM.
2. Set LOC:=1.
3. Repeat while a[LOC] != ITEM:
Set LOC:=LOC + 1.
[End of loop.]
4. If LOC = n+1,
then Set LOC:=0. [Unsuccessful]
5. Exit.
[3]](https://image.slidesharecdn.com/daa-180614051411/75/LINEAR-SEARCH-8-2048.jpg)
![COMPLEXITY [1]
CASES
TIME
COMPLEXITY
Best
Average
Worst
O(1)
O(n)
O(n)
1
(n+1)/2
n
F(n)
(COMPARISION)](https://image.slidesharecdn.com/daa-180614051411/75/LINEAR-SEARCH-9-2048.jpg)
