#define size 10
void sort ( int[]);
void seqsearch (int[], int);
void binarysearch (int [], int);
void main ()
{
int list[] = {10,19,18,17,16,15,14,13,12,11};
int target;
int i;
printf("\nEnter the value to search : ");
scanf("%d",&target);
seqsearch(list,target);
sort (list);
binarysearch (list,target);
printf("\n\t\tSORTED LIST\n");
for (i=0; i
}
void seqsearch(int list[], int t)
{
int i=0;
printf("\n\t\tSequential Search Technique\n");
while(i
if( i
else
printf("\nTarget not in the list\n");
}
void sort(int list[])
{
int i,j,temp;
for(i=0; i
{
temp=list[i];
list[i]=list[j];
list[j]=temp;
}
}
void binarysearch(int list[],int t)
{
printf("\n\t\tBinary Search Technique\n");
int mid,first=0, last=size-1;
while(first
mid=(first+last)/2;
if(t>list[mid])
first=mid+1;
else if(t
else
break;
}
if(t==list[mid])
printf("\nTarget was found in location %d \n",mid);
else
printf("\nTarget not in the list\n");
}