<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by mahipal Bamaniya on Medium]]></title>
        <description><![CDATA[Stories by mahipal Bamaniya on Medium]]></description>
        <link>https://medium.com/@mmbamaniya123?source=rss-a03b46c10e75------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FE2z2GGnBgqQnWvRKwLPbw.jpeg</url>
            <title>Stories by mahipal Bamaniya on Medium</title>
            <link>https://medium.com/@mmbamaniya123?source=rss-a03b46c10e75------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:20:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mmbamaniya123/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Minimum Spanning Tree Algorithm]]></title>
            <link>https://medium.com/@mmbamaniya123/minimum-spanning-tree-algorithm-4d079f3c8d0c?source=rss-a03b46c10e75------2</link>
            <guid isPermaLink="false">https://medium.com/p/4d079f3c8d0c</guid>
            <dc:creator><![CDATA[mahipal Bamaniya]]></dc:creator>
            <pubDate>Thu, 05 Sep 2019 05:11:33 GMT</pubDate>
            <atom:updated>2019-09-05T05:11:33.430Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*2vZbzYwhIXC3uPS-bKlEWA.png" /></figure><h3>Spanning tree</h3><p>A Spanning tree of a graph is just a sub-graph that contains all the vertices and do not contain any cycle.</p><p>A graph may have many spanning trees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CNfLduQFk0bYgE91NwxhDg.jpeg" /></figure><h3>Greedy Algorithms to find MST</h3><ol><li>Krushkal’s Algorithm</li><li>Prim’s Algorithm</li></ol><p>Krushkal’s Algorithm and Prim’s minimum spaning tree Algorithm are two popular Algorithms to find the minimum spaning trees.</p><h3>1.Krushkal’s Algorithm</h3><p>The algorithm is a Greedy Algorithm. The Greedy Choice is to pick the smallest weight edge that does not cause a cycle in the MST constructed so far. Let us understand it with an example: Consider the below input graph.</p><h3>Ex:1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s0RNT_ZV4f-uc17srqVYxQ.jpeg" /></figure><h3>Solution:</h3><p>The graph contains 5 vertices and 7 edges. So, the minimum spanning tree formed will be having (5 – 1) = 4 edges.</p><p>Now pick all edges one by one from sorted list of edges</p><p>1.Pick edge A,B:-No cycle is formed, include it</p><p>2.Pick edge E,D:-No cycle is formed, include it</p><p>3.Pick edge B,C:-No cycle is formed, include it</p><p>4.Pick edge C,D:-No cycle is formed, include it</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cZOhnQgldWGFEdrepvjvA.jpeg" /></figure><p>The next edge to be added is AE, but it can’t be added as it will contain a cycle.</p><p>Hence, the final MST is the one which is shown in the step 4.</p><p>the cost of MST = 1 + 2 + 3 + 4 = 10.</p><h3>Prim’s algorithm</h3><p>Prim’s Algorithm is used to find the minimum spanning tree from a graph.</p><h3>Ex:1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*oSAiR0xgoCtlgpPhGIrotg.png" /></figure><h3>Solution</h3><p>Step 1 : Choose a starting vertex B.</p><p>Step 2: Add the vertices that are adjacent to A. the edges that connecting the vertices are shown by dotted lines.</p><p>Step 3: Choose the edge with the minimum weight among all. i.e. BD and add it to MST. Add the adjacent vertices of D i.e. C and E.</p><p>Step 3: Choose the edge with the minimum weight among all. In this case, the edges DE and CD are such edges. Add them to MST and explore the adjacent of C i.e. E and A.</p><p>Step 4: Choose the edge with the minimum weight i.e. CA. We can&#39;t choose CE as it would cause cycle in the graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*pv9LBjIfH8ZcAOXcp8OXXQ.png" /></figure><p>the cost of MST = 4+1+2+3 = 10</p><h3>Applications</h3><p>Civil Network Planning</p><p>Computer Network Routing Protocol</p><p>Cluster Analysis</p><h3>Thank you</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d079f3c8d0c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[•Making change problem using Greedy method]]></title>
            <link>https://medium.com/@mmbamaniya123/making-change-problem-using-greedy-method-8670fe02d637?source=rss-a03b46c10e75------2</link>
            <guid isPermaLink="false">https://medium.com/p/8670fe02d637</guid>
            <dc:creator><![CDATA[mahipal Bamaniya]]></dc:creator>
            <pubDate>Tue, 03 Sep 2019 07:19:28 GMT</pubDate>
            <atom:updated>2019-09-03T07:19:28.254Z</atom:updated>
            <content:encoded><![CDATA[<p>The greedy approach is easy to understand and implement as well.We start with using the largest denomination coin. Once the owed amount is less than the largest, we move to next largest coin, so on.</p><p>Denominations are entered in descending order. That is largest one first. Example: 20, 10,5, 1 and amount is 36. And show in below figure.Here 4 coin is Use.We can add a sort method if it’s not, a minor change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RISNojLWzlJsrmip2Qm9NA.jpeg" /></figure><h3>Limitation</h3><p>Greedy approach works best with Canonical Coin systems and may not produce optimal results in arbitrary coin systems. For example, if denominations are {4, 3, 1}, number 6 is represented as 4×1 3×0 1×2 by this program taking 3 coins. The correct answer in this case is 4×0 3×2 1×0 with just 2 coins.</p><h3>Code</h3><p>#include&lt;iostream&gt;<br>using namespace std;<br>int main()<br>{<br> int deno,coinlist[30],coinuse[30],i;<br> cout&lt;&lt;&quot;enter number of denominator:&quot;&lt;&lt;endl;<br> cin&gt;&gt;deno;<br> cout&lt;&lt;&quot;enter the denomination in descending order:&quot;&lt;&lt;endl;<br> for(i=0;i&lt;deno;i++)<br> {<br> cin&gt;&gt;coinlist[i];<br> }<br> int coin;<br> cout&lt;&lt;&quot;enter the amount:&quot;&lt;&lt;endl;<br> cin&gt;&gt;coin;<br> for(i=0;i&lt;deno;i++)<br> {<br> coinuse[i]=coin/coinlist[i];<br> coin%=coinuse[i];<br> }<br> cout&lt;&lt;&quot;Solution:&quot;&lt;&lt;endl;<br> for(i=0;i&lt;deno;i++)<br> {<br> cout&lt;&lt;coinlist[i]&lt;&lt;&quot; &quot;&lt;&lt;coinuse[i];<br> }<br>}</p><h3>OUTPUT</h3><p>Enter number of denominator:4</p><p>enter the denomination in descending order:40 33 22 10</p><p>Enter the amount:43</p><p>Solution:</p><p>40×0 33×1 22×0 10×1</p><h3>Reference</h3><h4>“Introduction to Algorithm” by Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein.</h4><h3>Thank you</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8670fe02d637" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>