Showing posts with label merge sort implementation in c. Show all posts
Showing posts with label merge sort implementation in c. Show all posts

Saturday, May 18, 2013

Merge Sort Algorithm with C source Codes

Here, I've presented the merge sort algorithm as the straight merge sort. The basic idea is to break the file into n subfiles of size 1 and merge adjacent disjoint pairs of files and repeating the process until we've single file remaining of size n.
 The C Source codes is as follows:


// Merge sort implementation in C
#include<stdio.h>

void getdata(int arr[],int n)
{
 int i;
  printf("\nEnter the data:");
  for(i=0;i<n;i++)
    {
     scanf("%d",&arr[i]);
    }
}