<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Merge sort | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/merge-sort/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 27 Jan 2011 13:35:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>C++ rogram to implement merge sort</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Tue, 01 Feb 2011 13:34:06 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[Source Codes]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[Merge sort]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1236</guid>

					<description><![CDATA[<p>#include const int MAX = 5 ; class array { private : int *a ; int size ; int count ; public : array( ) ; array ( int sz ) ; void add ( int num ) ; void display( ) ; void merge_sort(int low,int high); void merge(int low,int mid,int high); ~array( ) ;</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/">C++ rogram to implement merge sort</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#include <iostream.h>
const int MAX = 5 ;
class array
{
	private :
		int *a ;
		int size ;
		int count ;
	public :
		array( ) ;
		array ( int sz ) ;
		void add ( int num ) ;
		void display( ) ;
		void merge_sort(int low,int high);
		void merge(int low,int mid,int high);
		~array( ) ;
} ;
array :: array( )
{
	count = size = 0 ;
	a = NULL ;
}
array :: array( int sz )
{
	count = 0 ;
	size = sz ;
	a = new int[sz] ;
}
void array :: add ( int num )
{
	if ( count < size )
	{
		a[count] = num ;
		count++ ;
	}
	else
		cout << "\nArray is full" << endl ;
}
void array :: display( )
{
	for ( int i = 0 ; i < count ; i++ )
		cout << a[i] << "\t" ;
	cout << endl ;
}
void array :: merge_sort(int low,int high)
{

	int mid;
	if(low<high)
	{
		mid=(low+high)/2;
		merge_sort(low,mid);
		merge_sort(mid+1,high);
		merge(low,mid,high);
	}
}
void array :: merge(int low,int mid,int high)
{
	int h,i,j,b[50],k;
	h=low;
	i=low;
	j=mid+1;

	while((h<=mid)&#038;&#038;(j<=high))
	{
		if(a[h]<=a[j])
		{
			b[i]=a[h];
			h++;
		}
		else
		{
			b[i]=a[j];
			j++;
		}
		i++;
	}
	if(h>mid)
	{
		for(k=j;k<=high;k++)
		{
			b[i]=a[k];
			i++;
		}
	}
	else
	{
		for(k=h;k<=mid;k++)
		{
			b[i]=a[k];
			i++;
		}
	}
	for(k=low;k<=high;k++) a[k]=b[k];
}
array :: ~array( )
{
	delete a ;
}

void main( )
{
	array a ( MAX ) ;

	a.add ( 11 ) ;
	a.add ( 2 ) ;
	a.add ( 9 ) ;
	a.add ( 13 ) ;
	a.add ( 57 ) ;

	cout << "\nMerge sort.\n" ;

	a.merge_sort (0,4) ;

	cout << "\nArray after sorting: " << endl ;
	a.display( ) ;
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/">C++ rogram to implement merge sort</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-rogram-to-implement-merge-sort/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>C++ programs for sorting a given numbers in ascending order using Merge sort</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-programs-for-sorting-a-given-numbers-in-ascending-order-using-merge-sort/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-programs-for-sorting-a-given-numbers-in-ascending-order-using-merge-sort/#comments</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Thu, 11 Mar 2010 17:34:12 +0000</pubDate>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[C Programs]]></category>
		<category><![CDATA[ascending order]]></category>
		<category><![CDATA[Merge sort]]></category>
		<category><![CDATA[cpp sorting]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1038</guid>

					<description><![CDATA[<p>/* Write C++ programs for sorting a given list of elements in ascending order using Merge sort methods */ #include #include using namespace std; void mergesort(int *,int,int); void merge(int *,int,int,int); int a[20],i,n,b[20]; main() { cout n; cout</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-programs-for-sorting-a-given-numbers-in-ascending-order-using-merge-sort/">C++ programs for sorting a given numbers in ascending order using Merge sort</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>/* Write C++ programs for sorting a given list of elements in ascending order using Merge sort methods */</p>
<pre lang="cpp">
#include<iostream>
#include<conio.h>
using namespace std;
void mergesort(int *,int,int);
void merge(int *,int,int,int);
int a[20],i,n,b[20];

main()
{
cout <<"\n enter no of elements";
cin >> n;
cout <<"enter the elements";
for(i=0;i<n;i++)
cin >> a[i];
mergesort(a,0,n-1);
cout <<" numbers after sort";
for(i=0;i<n;i++)
cout << a[i] << " ";
getch();
}

void mergesort(int a[],int i,int j)
{
   int mid;
   if(i<j)
   {
      mid=(i+j)/2;
      mergesort(a,i,mid);
      mergesort(a,mid+1,j);
      merge(a,i,mid,j);
   }
}
void merge(int a[],int low,int mid ,int high)
{
   int h,i,j,k;
   h=low;
   i=low;
    j=mid+1;
   while(h<=mid &#038;&#038; j<=high)
   {
      if(a[h]<=a[j])
	 b[i]=a[h++];
      else
	 b[i]=a[j++];
      i++;
   }

   if( h > mid)
      for(k=j;k<=high;k++)
	b[i++]=a[k];
   else
      for(k=h;k<=mid;k++)
	 b[i++]=a[k];

   cout <<"\n";
   for(k=low;k<=high;k++)
   {  a[k]=b[k];
     cout << a[k] <<" ";
   }

}
</pre>
<p><strong>OUTPUT</strong></p>
<p>N enter no of elements8 12 5 61 60 50 1 70 81<br />
enter the elements<br />
5 12<br />
60 61<br />
5 12 60 61<br />
1 50<br />
70 81<br />
1 50 70 81<br />
1 5 12 50 60 61 70 81  numbers after sort1 5 12 50 60 61 70 81</p><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-programs-for-sorting-a-given-numbers-in-ascending-order-using-merge-sort/">C++ programs for sorting a given numbers in ascending order using Merge sort</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-basic/c-programs-for-sorting-a-given-numbers-in-ascending-order-using-merge-sort/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
	</channel>
</rss>
