<?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>electrofriends.com &#187; Insertion sort</title>
	<atom:link href="http://electrofriends.com/tag/insertion-sort/feed/" rel="self" type="application/rss+xml" />
	<link>http://electrofriends.com</link>
	<description>...bringing innovative minds together</description>
	<lastBuildDate>Tue, 07 Feb 2012 08:43:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.6</generator>
		<item>
		<title>C++ program to implement Insertion sort using class</title>
		<link>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-basic-programs/c-program-to-implement-insertion-sort-using-class/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-basic-programs/c-program-to-implement-insertion-sort-using-class/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 13:27:51 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Insertion sort]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1230</guid>
		<description><![CDATA[#include &#60;iostream.h&#62; const int MAX = 10 ; class array &#123; private : int arr&#91;MAX&#93; ; int count ; public : array&#40; &#41; ; void add &#40; int item &#41; ; void sort&#40; &#41; ; void display&#40; &#41; ; &#125; ; array :: array&#40; &#41; &#123; count = 0 ; for &#40; int i = [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;iostream.h&gt;</span>
<span style="color: #0000ff;">const</span> <span style="color: #0000ff;">int</span> MAX <span style="color: #000080;">=</span> <span style="color: #0000dd;">10</span> <span style="color: #008080;">;</span>
<span style="color: #0000ff;">class</span> array
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">private</span> <span style="color: #008080;">:</span>
		<span style="color: #0000ff;">int</span> arr<span style="color: #008000;">&#91;</span>MAX<span style="color: #008000;">&#93;</span> <span style="color: #008080;">;</span>
		<span style="color: #0000ff;">int</span> count <span style="color: #008080;">;</span>
	<span style="color: #0000ff;">public</span> <span style="color: #008080;">:</span>
		array<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> add <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> item <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> sort<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> display<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span> <span style="color: #008080;">;</span>
array <span style="color: #008080;">::</span> <span style="color: #007788;">array</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	count <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> MAX <span style="color: #008080;">;</span> i<span style="color: #000040;">++</span> <span style="color: #008000;">&#41;</span>
		arr<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> array <span style="color: #008080;">::</span> <span style="color: #007788;">add</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> item <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> count <span style="color: #000080;">&lt;</span> MAX <span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		arr<span style="color: #008000;">&#91;</span>count<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> item <span style="color: #008080;">;</span>
		count<span style="color: #000040;">++</span> <span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">else</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Array is full&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> array <span style="color: #008080;">::</span> <span style="color: #007788;">sort</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> temp <span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;=</span> count <span style="color: #000040;">-</span> <span style="color: #0000dd;">1</span> <span style="color: #008080;">;</span> i<span style="color: #000040;">++</span> <span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> j <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #008080;">;</span> j <span style="color: #000080;">&lt;</span> i <span style="color: #008080;">;</span> j<span style="color: #000040;">++</span> <span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> arr<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&gt;</span> arr<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#41;</span>
			<span style="color: #008000;">&#123;</span>
				temp <span style="color: #000080;">=</span> arr<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #008080;">;</span>
				arr<span style="color: #008000;">&#91;</span>j<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> arr<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #008080;">;</span>
				<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> k <span style="color: #000080;">=</span> i <span style="color: #008080;">;</span> k <span style="color: #000080;">&gt;</span> j <span style="color: #008080;">;</span> k<span style="color: #000040;">--</span> <span style="color: #008000;">&#41;</span>
					arr<span style="color: #008000;">&#91;</span>k<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> arr<span style="color: #008000;">&#91;</span>k <span style="color: #000040;">-</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span> <span style="color: #008080;">;</span>
				arr<span style="color: #008000;">&#91;</span>k <span style="color: #000040;">+</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> temp <span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> array <span style="color: #008080;">::</span> <span style="color: #007788;">display</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> count <span style="color: #008080;">;</span> i<span style="color: #000040;">++</span> <span style="color: #008000;">&#41;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> arr<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span> <span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0000ff;">void</span> main<span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
	array a <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">add</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">25</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">add</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">17</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">add</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">31</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">add</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">13</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">add</span> <span style="color: #008000;">&#40;</span> <span style="color: #0000dd;">2</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Insertion sort.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Array before sorting:&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">display</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">sort</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Array after insertion sorting:&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #008080;">;</span>
	a.<span style="color: #007788;">display</span><span style="color: #008000;">&#40;</span> <span style="color: #008000;">&#41;</span> <span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/cpp-programs/cpp-basic-programs/c-program-to-implement-insertion-sort-using-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Insertion sort in C program</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/sorting-programs/program-to-sort-the-numbers-using-insertion-sort/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/sorting-programs/program-to-sort-the-numbers-using-insertion-sort/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 06:12:42 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Sorting Programs]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[C/C++ Programms]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Insertion sort]]></category>
		<category><![CDATA[logic]]></category>
		<category><![CDATA[sort in c]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[sorting demo]]></category>
		<category><![CDATA[sorting in c]]></category>
		<category><![CDATA[sorting numbers]]></category>
		<category><![CDATA[Source Codes]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=351</guid>
		<description><![CDATA[Here is the program to sort the given integer in ascending order using insertion sort method. Please find the pictorial tutor of the insertion sorting. Logic : Here, sorting takes place by inserting a particular element at the appropriate position, that&#8217;s why the name-  insertion sorting. In the First iteration, second element A[1] is compared [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the program to sort the given integer in ascending order using insertion sort method. Please find the pictorial tutor of the insertion sorting. </p>
<p><strong>Logic :</strong> Here, sorting takes place by inserting a particular element at the appropriate position, that&#8217;s why the name-  insertion sorting. In the First iteration, second element A[1] is compared with the first element A[0]. In the second iteration third element is compared with first and second element. In general, in every iteration an element is compared with all the elements before it. While comparing if it is found that the element can be inserted at a suitable position, then space is created for it by shifting the other elements one position up and inserts the desired element at the suitable position. This procedure is repeated for all the elements in the list.</p>
<p>If we complement the if condition in this program, it will give out the sorted array in descending order. Sorting can also be done in other methods, like selection sorting and bubble sorting, which follows in the next pages.</p>
<div id="attachment_912" class="wp-caption aligncenter" style="width: 590px"><img class="size-full wp-image-912" title="Insertion Sort Demo" src="http://electrofriends.com/wp-content/uploads/2008/12/insertion_sort.jpg" alt="Insertion Sort Demo" width="580" height="1332" /><p class="wp-caption-text">Insertion Sort Demo</p></div>
<p><strong>C program for Insertion Sort:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include&lt;stdio.h&gt;</span>
<span style="color: #993333;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #993333;">int</span> A<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">20</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> N<span style="color: #339933;">,</span> Temp<span style="color: #339933;">,</span> i<span style="color: #339933;">,</span> j<span style="color: #339933;">;</span>
	clrscr<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span> ENTER THE NUMBER OF TERMS...: &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>N<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span> ENTER THE ELEMENTS OF THE ARRAY...:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>N<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		gotoxy<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">25</span><span style="color: #339933;">,</span><span style="color: #0000dd;">11</span><span style="color: #339933;">+</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>%d&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>A<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>N<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		Temp <span style="color: #339933;">=</span> A<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		j <span style="color: #339933;">=</span> i<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>Temp<span style="color: #339933;">&lt;</span>A<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> j<span style="color: #339933;">&gt;=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			A<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> A<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			j <span style="color: #339933;">=</span> j<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		A<span style="color: #009900;">&#91;</span>j<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Temp<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span>THE ASCENDING ORDER LIST IS...:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>N<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>%d&quot;</span><span style="color: #339933;">,</span> A<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	getch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><a href="http://electrofriends.com/wp-content/uploads/2008/12/ins_srt.zip">Download exe and source code here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/sorting-programs/program-to-sort-the-numbers-using-insertion-sort/feed/</wfw:commentRss>
		<slash:comments>140</slash:comments>
		</item>
		<item>
		<title>Sorting of numbers</title>
		<link>http://electrofriends.com/articles/computer-science/c-tutorials/sorting-of-numbers/</link>
		<comments>http://electrofriends.com/articles/computer-science/c-tutorials/sorting-of-numbers/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 20:04:34 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Bubble sort]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[demo in sorting]]></category>
		<category><![CDATA[graphics program]]></category>
		<category><![CDATA[Insertion sort]]></category>
		<category><![CDATA[Selection sort]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=44</guid>
		<description><![CDATA[Sorting means arranging a set of data in some order. There are different methods that are used to sort the data in ascending order. Some of the  methods are Selection sort Bubble sort Insertion sort 1. Selection sort Here, to sort the data in ascending order, the 0th element is compared with all other elements. [...]]]></description>
			<content:encoded><![CDATA[<p>Sorting means arranging a set of data in some order. There are different methods that are used to sort the data in ascending order. Some of the  methods are</p>
<ol>
<li> Selection sort</li>
<li> Bubble sort</li>
<li> Insertion sort</li>
</ol>
<p><strong>1. Selection sort</strong></p>
<p>Here, to sort the data in ascending order, the 0th element is compared with all other elements. If it is greater than the compared element then they are interchanged. So after the first iteration smallest element is placed at the 0th position. The same procedure is repeated for the 1st element and so on. <a href="http://electrofriends.com/source-codes/software-programs/c/sorting-programs/program-to-sort-the-numbers-using-selection-sort/">Read more&#8230;</a></p>
<p><strong>2. Bubble sort</strong></p>
<p>Here, to sort the data in ascending order, 0th element is compared with the 1st element. If it is greater than the 1st element then they are interchanged else remains same. Then 1st element is compared with 2nd element and procedure is continued. So after the first iteration largest element is placed at the last position. In the second iteration, the comparisons are made till the last but one position and now second largest element is placed at the second last position. After all the iterations, the list becomes sorted. <a href="http://electrofriends.com/source-codes/software-programs/c/sorting-programs/program-to-sort-the-numbers-using-bubble-sort/">Read more&#8230;</a></p>
<p><strong>3. Insertion sort</strong></p>
<p>Here, sorting takes place by inserting a particular element at the appropriate position. To sort the element in ascending order, in first iteration,1st element is compared with the 0th element. In the second iteration 2nd element is compared with 0th and 1st element. In general, in every iteration an element is compared with all the elements before it. While comparing if it is found that the element in question can be inserted at a suitable position, then space is created for it by shifting the other element one position to the right and inserting the element at the suitable position. This procedure is repeated for all the elements in the list. <a href="../source-codes/software-programs/c/sorting-programs/program-to-sort-the-numbers-using-insertion-sort/">Read more&#8230;</a></p>
<p>In my program, you can enter 5 numbers which are to be sorted by any one of the above methods. After entering the numbers they are shown in red colour box and while comparison is done, the two elements which are compared are shown in green colour box. After sorting the elements, their permanent position is indicated by blue colour box. <a href="http://electrofriends.com/wp-content/uploads/2008/11/sort.zip">Click here to download the program</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/articles/computer-science/c-tutorials/sorting-of-numbers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

