Embed presentation
Download to read offline





![#include <stdio.h>
int LINEAR_SEARCH(int inp_arr[], int size, int val)
{
for (int i = 0; i < size; i++)
if (inp_arr[i] == val)
return i;
return -1;
}
int main(void)
{
int arr[] = { 10, 20, 30, 40, 50, 100, 0 };
int key = 100;
int size = 10;
int res = LINEAR_SEARCH(arr, size, key);
if (res == -1)
printf("ELEMENT NOT FOUND!!");
else
printf("Item is present at index %d", res);
return 0;
}](https://image.slidesharecdn.com/abdulla-240423120336-9a53252a/85/abdulla-time-complexity-and-linear-search-pptx-6-320.jpg)


The document explains the concept of searching for a specific element within a list, highlighting successful and unsuccessful outcomes based on element presence. It describes linear search as the simplest method, which involves checking each element sequentially until a match is found or the list is exhausted. Additionally, a sample C code implementation of linear search is provided.





![#include <stdio.h>
int LINEAR_SEARCH(int inp_arr[], int size, int val)
{
for (int i = 0; i < size; i++)
if (inp_arr[i] == val)
return i;
return -1;
}
int main(void)
{
int arr[] = { 10, 20, 30, 40, 50, 100, 0 };
int key = 100;
int size = 10;
int res = LINEAR_SEARCH(arr, size, key);
if (res == -1)
printf("ELEMENT NOT FOUND!!");
else
printf("Item is present at index %d", res);
return 0;
}](https://image.slidesharecdn.com/abdulla-240423120336-9a53252a/85/abdulla-time-complexity-and-linear-search-pptx-6-320.jpg)

