<?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 Kaushal H Mistry on Medium]]></title>
        <description><![CDATA[Stories by Kaushal H Mistry on Medium]]></description>
        <link>https://medium.com/@kaushalmistry2611?source=rss-71fcbf4bc019------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*-7DI1YdoN0C0JDh0zanOwA.jpeg</url>
            <title>Stories by Kaushal H Mistry on Medium</title>
            <link>https://medium.com/@kaushalmistry2611?source=rss-71fcbf4bc019------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:47:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kaushalmistry2611/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[Let’s Get Rid of Those Stale Git Branches ]]></title>
            <link>https://medium.com/@kaushalmistry2611/lets-get-rid-of-those-stale-git-branches-e1b6e383f259?source=rss-71fcbf4bc019------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1b6e383f259</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Kaushal H Mistry]]></dc:creator>
            <pubDate>Wed, 30 Jul 2025 19:47:47 GMT</pubDate>
            <atom:updated>2025-07-30T19:47:47.232Z</atom:updated>
            <content:encoded><![CDATA[<p>You know that feeling when you run git branch and it spits out a <strong>massive list</strong> of old feature and bugfix branches that are already merged? Yeah, same. 😤</p><p>I recently got tired of this mess and thought, <em>“There’s got to be a smarter way to clean this up than running </em><em>git branch -D &lt;branch&gt; over and over again.&quot;</em></p><p>Well, turns out there is — and I’m here to share it with you.</p><p>🧹 TL;DR — Clean up all your merged local branches in one go!</p><pre># Linux/Mac<br>git fetch --prune<br>git branch -vv | grep &quot;gone&quot; | awk &#39;{print $1}&#39; | xargs git branch -D<br><br># Windows (PowerShell)<br>git fetch --prune<br>git branch -vv | Select-String -Pattern &quot;gone&quot; | ForEach-Object { git branch -D ($_.ToString().Trim().Split())[0] }</pre><p>🔍 Step 1: Check your existing local branches</p><p>First, let’s see what we’re dealing with:</p><pre>git branch</pre><p>You’ll probably see a mix of feature/xyz, bugfix/abc, and your main branches like dev and main.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0CpkdmKJKFlPaQwVK2Xn7A.png" /><figcaption>Output of <strong>git branch </strong>command</figcaption></figure><p>🔄 Step 2: Fetch updated info from the remote</p><p>To identify which branches are already deleted from the remote (but still lingering locally), run this:</p><pre>git fetch --prune</pre><p>This command syncs your local repo with the remote and <strong>marks branches that have been removed remotely</strong>.</p><p>👀 Step 3: View details with -vv</p><p>Now let’s run:</p><pre>git branch -vv</pre><p>This shows the tracking status of each branch. The key detail here? You’ll see [gone] next to branches that are <strong>already deleted on the remote</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTfM5JXHjgXGBEj6naqMLw.png" /><figcaption>Output of <strong>git branch -vv</strong> command</figcaption></figure><p>🎯 Step 4: List only the stale branches</p><p>Now let’s isolate just the branches with the [gone] tag so we can delete them in bulk.</p><p>For Linux/Mac:</p><pre>git branch -vv | grep &quot;gone&quot; | awk &#39;{print $1}&#39;</pre><p>For Windows (PowerShell):</p><pre>git branch -vv | Select-String -Pattern &quot;gone]&quot; | ForEach-Object { ($_.ToString().Trim().Split())[0] }</pre><p>This will give you a nice list of all local branches that no longer exist on the remote. 🎯</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*75aUKjmrNKHHG8aFxg-chA.png" /><figcaption>Filtering stale branches</figcaption></figure><h3>🔥 Step 5: Delete them all in one shot</h3><p>Now for the final sweep. Run the below to delete all those stale branches in one go:</p><p>Linux/Mac:</p><pre>git branch -vv | grep &quot;gone&quot; | awk &#39;{print $1}&#39; | xargs git branch -D</pre><p>Windows (PowerShell):</p><pre>git branch -vv | Select-String -Pattern &quot;gone]&quot; | ForEach-Object { git branch -D ($_.ToString().Trim().Split())[0] }</pre><p>Boom. 💣 All the old, merged, and remote-deleted branches are now <strong>gone from your local machine</strong> too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o4hcBLyOJmXI_svSpV8rHA.png" /><figcaption>Deleting stale branches at once</figcaption></figure><h3>✅ Final Output</h3><p>Now if you run:</p><pre>git branch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MT4Tj-_Zx2Uuaa7ZgO7a5A.png" /><figcaption>After removing all the stale branches</figcaption></figure><p>You’ll only see your active branches like main and dev. Clean, minimal, and much easier to navigate. ✨</p><h3>🏁 Wrapping Up</h3><p>And that’s it! You’ve successfully cleaned up your local Git branches like a pro! 🚀</p><p>No more scrolling through endless outdated feature branches. With just a couple of simple commands, you now have a neat and tidy branch list that actually reflects what you’re working on.</p><p>If this helped you, feel free to bookmark it or share it with your team. And if you’ve got any other cool Git tips, drop them in the comments. I’d love to hear them!</p><p>Happy coding! 🧑‍💻✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1b6e383f259" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master Theorem]]></title>
            <link>https://medium.com/@kaushalmistry2611/master-theorem-eb6764536a96?source=rss-71fcbf4bc019------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb6764536a96</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[analysis]]></category>
            <dc:creator><![CDATA[Kaushal H Mistry]]></dc:creator>
            <pubDate>Wed, 21 Aug 2019 21:04:58 GMT</pubDate>
            <atom:updated>2019-08-25T13:20:41.025Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Algorithm Cycle" src="https://cdn-images-1.medium.com/max/250/1*ILqTspzvMB4foBwqHWIzHA.png" /><figcaption>Image from google</figcaption></figure><p>When we have to solve a problem and when many ways are available to solve that problem (for example Matrix chain multiplication problem), at that time analysis of the algorithm is needed.</p><p>Analysis of algorithms means to estimate their complexity in an asymptotic sense. The term <strong>“analysis of algorithms”</strong> was coined by Donald Knuth. Analysis of algorithms is the determination of the amount of time and space resources required to execute it.</p><p>Most of the algorithms are recursive in nature, they use the divide and conquer strategy. The recursive algorithm calls itself for the other inputs. That is usually part of the original input but has a smaller size (sub-problem). There are many ways to solve the recurrence relation. They are as follows :</p><blockquote><em>1. Master theorem</em></blockquote><blockquote><em>2. Recurrence tree method</em></blockquote><blockquote><em>3. Substitution method</em></blockquote><blockquote><em>4. Change of variable method</em></blockquote><p>Among all these methods the master theorem is the fastest method to find the time complexity of the function. It is very easy to understand and easy to apply. We just have to remember some cases. So here we go.</p><h3>Master Theorem for Decreasing Functions :</h3><p>In decreasing functions, we are having forms like <strong><em>T(n) = T(n-1)+1</em></strong>, <strong><em>T(n)=2T(n-1)+n²</em></strong> etc.</p><blockquote><em>So the general form for decreasing functions will be</em></blockquote><blockquote><strong><em>T(n) = aT(n-b) + f(n)</em></strong><em>, where a and b are the constants. a&gt;0, b&gt;0 and </em><strong><em>f(n)=O(n^k)</em></strong><em> where k≥0. a = Number of subproblems and b = The cost of dividing and merging the subproblems.</em></blockquote><p>To solve this type of recurrence relation there are 3 cases :</p><blockquote><strong><em>Case : 1</em></strong></blockquote><p>If a&lt;1 then <strong>T(n) = O(n^k)</strong> or simply <strong>T(n) = O(f(n))</strong>.</p><p>Examples :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*jZop2VaTvoVQUPK4zPjphg.png" /></figure><blockquote><strong><em>Case : 2</em></strong></blockquote><p>If a = 1 then <strong>T(n) = O(n^(k+1))</strong> or simply <strong>T(n) = O(n*f(n)).</strong></p><p>Examples :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*5uCrlJ9Qufcly-4FSZfhYw.png" /></figure><blockquote><strong><em>Case : 3</em></strong></blockquote><p>If a&gt;1 then <strong>T(n) = O(a^(n/b) * f(n)).’</strong></p><p>Examples :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*J6d3Z7e10sHFcUAg0EaVpw.png" /></figure><p>Like decreasing functions, the master theorem can also be applied to dividing functions.</p><h3>Master theorem for Dividing functions :</h3><p>Dividing functions can be defined as <strong>T(n) = T(n/2) + c</strong>, <strong>T(n)=2T(n/2)+logn</strong>, etc.</p><blockquote><em>The general form for the dividing functions :</em></blockquote><blockquote><strong><em>T(n) = aT(n/b) + f(n)</em></strong><em>, where a and b are constants. </em><strong><em>a≥1, b&gt;1</em></strong><em> and </em><strong><em>f(n) can be expressed as O(n^k * (logn)^p). </em></strong><em>a = Number of subproblems and b = The cost of dividing and merging the subproblems.</em></blockquote><p>To find the time complexity for these kinds of functions again there are 3 cases. Here we have to find two things 1. loga base b and 2. k</p><p>For simplicity, let’s take <strong>loga base b as x </strong>for all below cases.</p><blockquote><strong><em>Case : 1</em></strong></blockquote><p>If k &lt; x then <strong>T(n) = O(n^x).</strong></p><p>Examples :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*6ULIqLQOEMk0hk2Sdj6yDg.png" /></figure><blockquote><strong><em>Case : 2</em></strong></blockquote><p>If k = x then again some cases here comes p in the picture :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*8h2prCvm2WwchomiYgDzlw.png" /></figure><p>Examples :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*qgXbpvKRUI8dPUluY5ihaA.png" /></figure><blockquote><strong><em>Case : 3</em></strong></blockquote><p>If k &gt; x then <strong>T(n) = O(f(n))</strong>.</p><p>Examples :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*GYfaOq4eHf95CYdvE-hVQw.png" /></figure><p>In this pretty simple way, Master Theorem works to find the complexity of decreasing and dividing functions.</p><p>We can use either Theta (Θ) Notation or Omega (Ω) Notation instead of Big O Notation.<strong> Using Θ notation will be more appropriate fo the master theorem.</strong></p><p>There are some limitations of this theorem. That is for some kind of relations it is unable to give the complexity.</p><blockquote><strong><em>Inadmissible relations :</em></strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*3FEYZSuWAtlUHZ_Ep0wI4g.png" /></figure><p>For the above examples, the Master theorem cannot be used.</p><p>That is all about Master Theorem for finding the time complexity of the algorithms.</p><p>References :</p><p><strong>“Introduction to Algorithm”</strong> by Thomas H Cormen, Charles E Leiserson, Ronald L Rivest, Clifford Stein.</p><blockquote>Thank You ☺</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb6764536a96" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big O Notation]]></title>
            <link>https://medium.com/@kaushalmistry2611/big-o-notation-103432369f63?source=rss-71fcbf4bc019------2</link>
            <guid isPermaLink="false">https://medium.com/p/103432369f63</guid>
            <category><![CDATA[analysis]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Kaushal H Mistry]]></dc:creator>
            <pubDate>Wed, 21 Aug 2019 06:16:45 GMT</pubDate>
            <atom:updated>2019-08-21T06:44:50.813Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*TeDBsBraTf4wFGTOJUoLdw.jpeg" /></figure><p>Before knowing about Big-O Notation let’s look at why we need this notation. Using this what we are going to do.</p><p>So before getting into this let’s look at <strong>the time complexity</strong>.</p><p>The time complexity simply means the time taken by the function to complete its execution. The time it takes to run your function as the size of input increases. Time complexity is commonly estimated by counting the number of elementary operations performed by the function or algorithm, supposing that each elementary operation takes a fixed amount of time to perform. Let&#39;s take an example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*sb-tKr4avnDNmW1E_pYOcA.png" /></figure><p>Looking at the example we would like to ask a question that how much time it takes to run this function? But this is not a valid question. Instead, we should ask how does the runtime of this function grow with respect to input size? This is a valid question to answer because according to the different size of input the function is going to take a different amount of time. So to answer the second question we use Big O Notation and the Time complexity.</p><p>In the above example, the print line will be repeated n times and it increases or decreases with n. So the time complexity for the function display will be linear, and if in the above example we replace n by 5 in the 2nd line (in for loop) then it is independent of the argument passed to it. In that case, the time complexity will be constant.</p><figure><img alt="Graph of the time complexity (Number of Elements vs. Time )" src="https://cdn-images-1.medium.com/max/640/1*jK2RSXJcfpRm35GARiGz1w.png" /></figure><p>Thus rather than specifying the time complexity as constant, linear, quadratic, we are having some special mathematical notation that is Big O notation.</p><p>There are other notations as well, like Big Omega, Theta Notation.</p><p>Among them, we are going to know about Big O Notation.</p><p>Big O notation defines an upper bound of an algorithm, it bounds a function only from above. So this works with the worst-case scenario. For example, consider the case of bubble sort. It takes linear time in the best case and quadratic time in the worst case. So we can safely say that the time complexity for bubble sort is O(n²). Here since Big O notation defines upper bound so it also covers the linear time complexity ( O(n) ).</p><p>Mathematically, Big O notation can be described as :</p><p><strong><em>f(n) = O(g(n)) if there exists constants c and n0, such that f(n) ≤ c*g(n) for all n≥n0 .</em></strong></p><p>We can simply express linear time complexity as O(n), constant time complexity as O(1) and quadratic time complexity as O(n²), where n is the number of inputs.</p><p>But how we came to know that the linear time complexity is O(n). So for that let&#39;s look at the example we saw earlier which was having linear time complexity. The time taken by the function(T) can be expressed as a linear function.</p><blockquote><strong>T = an + b ,</strong> where a and b are the constants.</blockquote><p>To find the Big O notation for the above simply follow simple two steps :</p><ol><li>Find the fastest growing term.</li><li>Take out the constant coefficients.</li></ol><p>In the above equation, as b is the constant so the function grows when n grows. So the fastest-growing term will be <strong>an, </strong>and in the second step remove constant coefficients(here a) so the only n remains as it is and that&#39;s goes into Big O expression. So the time complexity for <strong>T = an + b </strong>will be <strong>O(n)</strong>.</p><p>Let’s take another example,</p><blockquote><strong>T = cn² + dn +c ,</strong> where a, b and c are the constants</blockquote><p>Following the steps, the fastest-growing term will be <strong>cn² </strong>and in the second step removing the constant coefficients, we are left with <strong>n² </strong>which is our time complexity. So the time complexity of the above function will be <strong>O(n²)</strong>.</p><p>We can express O(n²) with O(n³) as well because of Big O defines upper bound of the function and n³ is bigger or upper than n².</p><figure><img alt="Properties of Big O Notation." src="https://cdn-images-1.medium.com/max/771/1*yJCQaXnVT0VSaypYcxDNng.png" /></figure><p>Algorithm examples of the runtime analysis are as follows :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*VehNTQp1eYlqAve6YUeMXg.png" /></figure><blockquote><em>Thank You :)</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=103432369f63" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>