Posts

Showing posts with the label Algorithm

Merge Sort Algorithm in c/c++

Merge Sort Algorithm in c/c++ #include<stdio.h> #include<conio.h> int a[100],b[100]; void mergesort(int low,int mid, int high) {             int h=low,i=low,j=mid+1;             while(h<=mid && j<=high)             {                         if(a[h]<a[j])                         {                                     b[i]=a[h];          ...

linked queue algorithm using c/c++

linked queue algorithm using c/c++ #include<stdio.h> #include<conio.h> int a[100],front=-1,rear=-1; void main() {                 clrscr();                 void iqueue();                 int dqueue();                 void diplayque();                 int n,ind;                 while(1)                 {                       ...

Link list using c++

Image
Link list using c++ Knowledge of linked lists is must for C programmers. This article explains the fundamentals of C linked list with an example C program. Linked list is a dynamic data structure whose length can be increased or decreased at run time. How Linked lists are different from arrays? Consider the following points : An array is a static data structure. This means the length of array cannot be altered at run time. While, a linked list is a dynamic data structure. In an array, all the elements are kept at consecutive memory locations while in a linked list the elements (or nodes) may be kept at any location but still connected to each other. #include<stdio.h> #include<conio.h> #include<alloc.h> #include<process.h> struct linklist {                 int n;                 struct ...

Binary Search Algorithm using c/c++

Binary Search Algorithm using c/c++ Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty. Binary search Program #include<stdio.h> #include<conio.h> void main() {                 int a[100],n,i,x;                 void sorts(int [],int);                 int binser(int [],int,int,int);                 clrscr();           ...