LINEAR SEARCH
PRESENTING BY-
BIJOYA LAISHRAM
CONTENTS
Introduction
An example
Algorithm
Its complexity
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]
45 36 20 68 70
Exampleof a linearsearch:-
Suppose the element that we want to
search is 68.
1 2 3 4 5
Target element = 68
45 36 20 68 70
 If the target element is not found at the
first search then the searching will be
continued to the next location.
1 2 3 4 5
Target element = 68
45 36 20 68 70
1 2 3 4 5
Target element = 68
 Again the searching will be continued
to the next location as the element is
not found yet.
45 36 20 68 70
1 2 3 4 5
Here, the target element is found at the
location= 4.
Searching is successful and further searching
is not needed.
Target element = 68
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]
COMPLEXITY [1]
CASES
TIME
COMPLEXITY
Best
Average
Worst
O(1)
O(n)
O(n)
1
(n+1)/2
n
F(n)
(COMPARISION)
THANK YOU

LINEAR SEARCH