Linear search
Linear search is a method for finding a particular value in a array list, that consists of checking every one of its elements, one at a time and in sequence, until the desired one is found.It is also known as sequential search.
Algorithm
Unordered-Linear-Search[A, n, x] 1. for i 1 to n 2. do if A[i] = x 3. then return i 4. else i i + 1 5. return “x not found”
Quick sort Implementation
#include<stdio.h> #include<conio.h> void main() { int a[10],i,n,m,c=0; clrscr(); printf("Enter the size of an array: "); scanf("%d",&n); printf("Enter the elements of the array: "); for(i=0;i<=n-1;i++) { scanf("%d",&a[i]); } printf("Enter the number to be search: "); scanf("%d",&m); for(i=0;i<=n-1;i++) { if(a[i]==m) { c=1; break; } } if(c==0) printf("The number is not in the list"); else printf("The number is found"); getch(); }