9. Implement Linear Search Algorithm
9. Implement Linear Search Algorithm
9
Aim: Implement Linear Search Algorithm.
LO:LO4: Students will be able to select appropriate searching techniques for given problems
Theory: Searching is the process of finding some particular element in the list. If the element is
present in the list, then the process is called successful and the process returns the location of that
element, otherwise the search is called unsuccessful.
There are two popular search methods that are widely used in order to search some item into the list.
However, choice of the algorithm depends upon the arrangement of the list.
Linear Search
Binary Search
Linear Search: Linear search is the simplest search algorithm and often called sequential search. In
this type of searching, we simply traverse the list completely and match each element of the list with
the item whose location is to be found. If the match found then location of the item is returned
otherwise the algorithm return NULL. Linear search is mostly used to search an unordered list in
which the items are not sorted.
Program:
#include<stdio.h>
void main ()
scanf("%d",&item);
{
if(a[i] == item)
flag = i+1;
break;
else
flag = 0;
if(flag != 0)
else
Output: