<?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 aesha bhavsar on Medium]]></title>
        <description><![CDATA[Stories by aesha bhavsar on Medium]]></description>
        <link>https://medium.com/@aeshabhavsar34f?source=rss-6b47a8f7aa49------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XjcxqeE8NI_yOrE8.jpg</url>
            <title>Stories by aesha bhavsar on Medium</title>
            <link>https://medium.com/@aeshabhavsar34f?source=rss-6b47a8f7aa49------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 12:31:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aeshabhavsar34f/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[Fractional Knapsack Problem Using Greedy Approach]]></title>
            <link>https://medium.com/@aeshabhavsar34f/fractional-knapsack-problem-using-greedy-approach-bde9a33782a2?source=rss-6b47a8f7aa49------2</link>
            <guid isPermaLink="false">https://medium.com/p/bde9a33782a2</guid>
            <category><![CDATA[greedy-algorithms]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[knapsack-problem]]></category>
            <category><![CDATA[fractional-greedy-method]]></category>
            <category><![CDATA[knapsack]]></category>
            <dc:creator><![CDATA[aesha bhavsar]]></dc:creator>
            <pubDate>Sat, 24 Aug 2019 18:13:04 GMT</pubDate>
            <atom:updated>2019-09-09T02:55:02.532Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Knapsack Problem-&gt;</strong><br>You are given a knapsack (a kind of shoulder bag) with a limited weight capacity and few items each having some weight and value.</p><p><strong>The problem states that-&gt;</strong><br>“Which items should be placed in the knapsack so that the value or profit that is obtained by putting the items in the knapsack is maximum and the weight limit of the knapsack also does not exceed?”</p><p><strong>Knapsack problem has the following two variants-&gt;</strong></p><ol><li><strong>Fractional Knapsack Problem</strong></li><li><strong>0/1 Knapsack Problem</strong></li></ol><p><strong><em>We will see here fractional knapsack problem solution.</em></strong></p><blockquote><strong>In Fractional Knapsack Problem,</strong></blockquote><blockquote>-As the name suggests, items are divisible here.<br>-We can even put the fraction of any item in the knapsack if taking the complete item is not possible.<br>-It is solved using Greedy Approach &amp; gives optimal solution which is not given by 0/1 knapsack problem.</blockquote><p><strong><em>Steps for solving Fractional Knapsack Problem using Greedy Approach-&gt;</em></strong><br><strong><em>Step-01: </em></strong>For each item, compute its value / weight ratio.<br><strong><em>Step-02: </em></strong>Arrange all the items in the decreasing order of their value / weight ratios.<br><strong><em>Step-03: </em></strong>Start putting the items in the Knapsack beginning from the item with the highest ratio. Put as many items as you can in the Knapsack.</p><blockquote><strong>PRACTICE PROBLEM BASED ON FRACTIONAL KNAPSACK PROBLEM USING GREEDY APPROACH-&gt;</strong></blockquote><blockquote><strong>Find the optimal solution for the fractional knapsack problem making use of greedy approach. Consider that…</strong></blockquote><blockquote><strong>n = 5</strong></blockquote><blockquote><strong>w = 60 kg</strong></blockquote><blockquote><strong>(w1, w2, w3, w4, w5) = (5, 10, 15, 22, 25)</strong></blockquote><blockquote><strong>(b1, b2, b3, b4, b5) = (30, 40, 45, 77, 90)</strong></blockquote><p><strong>Solution:-</strong><br><strong><em>Step-01:</em></strong><em><br>Compute the value / weight ratio for each item-&gt;</em></p><p>Items: ( 1 , 2 , 3 , 4 , 5 )</p><p>Value: ( 30 , 40 , 45 , 77 , 90 )</p><p>Weight: ( 5 , 10 , 15 , 22 , 25 )</p><p>Ratio: ( 6 , 4 , 3 , 3.5 , 3.6 )</p><p><strong><em>Step-02:</em></strong><br><em>Sort all the items in the decreasing order of their value / weight ratios-&gt;</em></p><p>I1 : 6</p><p>I2: 4</p><p>I5: 3.6</p><p>I4: 3.5</p><p>I3: 3</p><p><strong><em>Step-03:</em></strong><br><em>Start filling the knapsack by putting the items in it one by one.</em></p><p>Knapsack Weight : 60 , Items in the Knapsack: 0 , Profit : 0</p><p>Knapsack Weight : 60–5=55 , Items in the Knapsack: I1, Profit: 30</p><p>Knapsack Weight : 55–10=45 , Items in the Knapsack ( I1,I2 ) , Profit :30+40=70</p><p>Knapsack Weight : 45–25=20 , Items in the Knapsack: ( I1,I2,I5 ) , Profit :70+90=160</p><p><strong><em>Now,</em></strong></p><p><em>Knapsack weight left to be filled is 20 kg but item-4 has a weight of 22 kg.<br>-Had the problem been a 0/1 knapsack problem, we would have stopped and reported that the knapsack has items &lt; I1 , I2 , I5 &gt; and the knapsack’s total cost is 160.<br>-But because in fractional knapsack problem we can even take the fraction of any item.</em><br><em>-So, our knapsack will contain the items-&gt;</em><br> I1 , I2 , I5 , (20/22) I4</p><p><strong><em>Now,</em></strong><br>Total cost of the knapsack<br>= 160 + (20/22) * 77<br>= 230</p><blockquote><strong>So,final profit of knapsack problem, which we can get by fractional greedy method is, 230.<br>Thus,we can get optimal solution of knapsack problem using fractional greedy method…which overcomes the disadvantage of the 0/1 knapsack problem,that doesn’t give optimal solution.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bde9a33782a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asymptotic Analysis & Asymptotic Notations]]></title>
            <link>https://medium.com/@aeshabhavsar34f/asymptotic-analysis-asymptotic-notations-785d4c4fc89c?source=rss-6b47a8f7aa49------2</link>
            <guid isPermaLink="false">https://medium.com/p/785d4c4fc89c</guid>
            <category><![CDATA[asymptotic-notation]]></category>
            <category><![CDATA[asymptotic-analysis]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[aesha bhavsar]]></dc:creator>
            <pubDate>Sat, 24 Aug 2019 17:23:19 GMT</pubDate>
            <atom:updated>2019-08-24T17:23:19.715Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>In this article,you will learn what asymptotic notations are. Also, you will learn about Big-O notation, Theta notation and Omega notation.</blockquote><blockquote>The efficiency of an algorithm depends on the amount of time, storage and other resources required to execute the algorithm. The efficiency is measured with the help of asymptotic notations.</blockquote><blockquote>An algorithm may not have the same performance for different types of inputs. With the increase in the input size, the performance will change.</blockquote><blockquote>The study of change in performance of the algorithm with the change in the order of the input size is defined as asymptotic analysis.</blockquote><blockquote>Asymptotic notations are the mathematical notations used to describe the running time of an algorithm when the input tends towards a particular value or a limiting value.</blockquote><blockquote>For example: In bubble sort, when the input array is already sorted, the time taken by the algorithm is linear i.e. the best case.</blockquote><blockquote>But, when the input array is in reverse condition, the algorithm takes the maximum time (quadratic) to sort the elements i.e. the worst case.</blockquote><blockquote>When the input array is neither sorted nor in reverse order, then it takes average time.This duration is denoted using asymptotic notations.</blockquote><blockquote>There are mainly three asymptotic notations: Theta notation, Omega notation and Big-O notation.</blockquote><p><strong><em>1.Theta Notation (Θ-notation):</em></strong><em> Theta notation encloses the function from above and below. Since, it represents the upper and the lower bound of the running time of an algorithm, it is used for analyzing the average case complexity of an algorithm.<br>For a given function g(n), we denote T(g(n)) is following set of functions.</em></p><p><em>Θ(g(n)) = {f(n): there exist positive constants c1, c2 and n0 such that 0 &lt;= c1*g(n) &lt;= f(n) &lt;= c2*g(n) for all n &gt;= n0}.</em></p><p><em>The above expression can be described as a function f(n) belongs to the set Θ(g(n)) if there exist positive constants c1 and c2 such that it can be between c1*g(n) and c2*g(n), for sufficiently large n.<br>For any value of n, the running time of an algorithm does not cross time provided by Θ(g(n)).<br>If a function f(n) lies anywhere in between c1*g(n) and c2*g(n) for all n = n0, then f(n) is said to be asymptotically tight bound.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/174/1*M3MwhUVBp5XDgToeE5BDFw.png" /></figure><p><strong><em>2.Big-O Notation (O-notation): </em></strong><em>Big-O notation represents the upper bound of the running time of an algorithm. Thus, it gives the worst case complexity of an algorithm.<br>The Big O notation is useful when we only have upper bound on time complexity of an algorithm. Many times we easily find an upper bound by simply looking at the algorithm.<br>For a given function g(n), we denote T(g(n)) is following set of functions.</em></p><p><em>O(g(n)) = { f(n): there exist positive constants c and n0 such that 0 &lt;= f(n) &lt;= c*g(n) for all n &gt;= n0}.</em></p><p><em>The above expression can be described as a function f(n) belongs to the set O(g(n)) if there exists a positive constant c such that it lies between 0 and c*g(n), for sufficiently large n.<br>For any value of n, the running time of an algorithm does not cross time provided by O(g(n)).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/171/1*NwmwKYz6XNaZ5gD1ie6AZQ.png" /></figure><p><strong><em>3.Omega Notation (Ω-notation):</em></strong><em> Omega notation represents the lower bound of the running time of an algorithm. Thus, it provides best case complexity of an algorithm.<br>For a given function g(n), we denote T(g(n)) is following set of functions.</em></p><p><em>Ω(g(n)) = {f(n): there exist positive constants c and n0 such that 0 &lt;= c*g(n) &lt;= f(n) for all n &gt;= n0}.</em></p><p><em>The above expression can be described as a function f(n) belongs to the set Ω(g(n)) if there exists a positive constant c such that it lies above c*g(n), for sufficiently large n.<br>For any value of n, the minimum time required by the algorithm is given by Omega Ω(g(n)).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*8D2iTjhsihPe1q8UWfSq1A.png" /></figure><blockquote><strong>There are two more notations called little o and little omega. Little o provides strict upper bound (equality condition is removed from Big O) and little omega provides strict lower bound (equality condition removed from big omega).</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=785d4c4fc89c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>