<?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 Nirali ladva on Medium]]></title>
        <description><![CDATA[Stories by Nirali ladva on Medium]]></description>
        <link>https://medium.com/@ladvan756?source=rss-20d1486fd34c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*J2LqnazjPHMCz72Z.jpg</url>
            <title>Stories by Nirali ladva on Medium</title>
            <link>https://medium.com/@ladvan756?source=rss-20d1486fd34c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:36:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ladvan756/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[Longest Common Subsequence]]></title>
            <link>https://medium.com/@ladvan756/longest-common-subsequence-1335acad54ff?source=rss-20d1486fd34c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1335acad54ff</guid>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Nirali ladva]]></dc:creator>
            <pubDate>Sun, 08 Sep 2019 20:15:09 GMT</pubDate>
            <atom:updated>2019-09-12T17:10:23.680Z</atom:updated>
            <content:encoded><![CDATA[<h4>Finding the longest sequence which exists in both the given strings.</h4><p>We are given two strings: string X of length n, and string Y of length m. Our goal is to produce their longest common subsequence: the longest sequence of characters that appear left-to-right (but not necessarily in a contiguous block) in both strings.</p><p><strong>Application : -</strong></p><ul><li>Data Mining</li><li>Modeling Market Traders</li><li>Used in plagiarism</li></ul><p>For example, consider:</p><p>X=BACDB</p><p>Y=BDCB</p><p>Let’s now solve the LCS problem using Dynamic Programming. As subproblems we will look at the LCS of a prefix of X and a prefix of Y, running over all pairs of prefixes. For simplicity, let’s worry first about finding the length of the LCS and then we can modify the algorithm to produce the actual sequence itself.</p><h3>Formula:</h3><p>a[i,j]=</p><p>if(Xi=Yi=0) →0</p><p>if (Xi=Yi) {1+a[i-1,j-1]}</p><p>else{(max(a[i-1,j],a[i,j-1])}</p><p>case 1:if value of uper cell and left side cell is zero then ans of current cell is zero.</p><p>case 2: if both character are equal then go to diagonally and add one to whatever value that is stored on diagonal cell.</p><p>case 3: if both character are not equal then goto up side and compere its value with left side cell and whatever is max put the value.</p><p><strong>How to calculate a least common sub sequence : -</strong></p><p>In this example, we have two strings <strong><em>X = BACDB</em></strong> and <strong><em>Y = BDCB</em></strong> to find the longest common subsequence.</p><p>Following the algorithm LCS-Length-Table-Formulation (as stated above), we have calculated table C (shown on the left hand side) and table B (shown on the right hand side).</p><p>In table B, instead of ‘D’, ‘L’ and ‘U’, we are using the diagonal arrow, left arrow and up arrow, respectively. After generating table B, the LCS is determined by function LCS-Print. The result is BCB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*_IxSwVHH-OrZpzVZ.jpg" /><figcaption>process of finding a least common subsequence</figcaption></figure><p>How can we now find the sequence? To find the sequence, we just walk backwards through matrix starting the lower-right corner. If either the cell directly above or directly to the right contains a value equal to the value in the current cell, then move to that cell (if both to, then chose either one). If both such cells have values strictly less than the value in the current cell, then move diagonally up-left (this corresponts to applying Case 2), and output the associated character. This will output the characters in the LCS in reverse order.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1335acad54ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Change Problem Using Daynamic Programming]]></title>
            <link>https://medium.com/@ladvan756/making-change-problem-using-daynamic-programming-ac7cbafb8581?source=rss-20d1486fd34c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac7cbafb8581</guid>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Nirali ladva]]></dc:creator>
            <pubDate>Sun, 08 Sep 2019 19:55:34 GMT</pubDate>
            <atom:updated>2019-09-09T02:57:19.258Z</atom:updated>
            <content:encoded><![CDATA[<h4>The change-making problem address the question of finding the minimum number of coins that add up to a given amount of money.</h4><p>The coin change problem, we are basically provided with coins with different denominations like 1Rs., 5Rs. and 10Rs. Now, we have to make an amount by using these coins such that a minimum number of coins are use.</p><ol><li>Using 1 coin of 10Rs.</li><li>Using two coins of 5Rs.</li><li>Using one coin of 5Rs. and 5 coins of 1Rs.</li><li>Using 10 coins of 1Rs.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/0*9LyO_n7fn0eb0FIP.png" /></figure><p>Out of these 4 ways of making 10Rs, we can see that the first way of using only one coin of 10Rs requires the least number of coins and thus it is our solution.</p><p>Now, we have to make change for the value nn using these coins and we need to find out the minimum number of coins required to make this change.</p><p>For example, we are making an optimal solution for an amount of 8 by using two values — 5 and 3. So, the optimal solution will be the solution in which 5 and 3 are also optimally made, otherwise, we can reduce the total number of coins of optimizing the values of 5 and 8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/0*DEy6gpvSs2lf7XUn.png" /></figure><p>The reason we are checking if the problem has optimal substructure or not because if there is optimal substructure, then the chances are quite high that using dynamic programming will optimize the problem.</p><h3>Making change in optimal solution:</h3><ul><li><strong>Formula:</strong></li></ul><p><strong><em>c[i , j]= min(c[i-1 , j] , 1 + c[i-1 , j-di])</em></strong></p><h3>Example:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3c7rWo6EBOWOPjknoZgxg.jpeg" /><figcaption>making change problem</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac7cbafb8581" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>