<?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 Richikghosh on Medium]]></title>
        <description><![CDATA[Stories by Richikghosh on Medium]]></description>
        <link>https://medium.com/@richikghosh19?source=rss-901017a6e34b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*S4kMicsisno8iOZv</url>
            <title>Stories by Richikghosh on Medium</title>
            <link>https://medium.com/@richikghosh19?source=rss-901017a6e34b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:38:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@richikghosh19/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[My Manifesto as a Writer]]></title>
            <link>https://medium.com/@richikghosh19/my-manifesto-as-a-writer-1ad7a1f17475?source=rss-901017a6e34b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ad7a1f17475</guid>
            <dc:creator><![CDATA[Richikghosh]]></dc:creator>
            <pubDate>Thu, 15 Sep 2022 18:18:43 GMT</pubDate>
            <atom:updated>2022-09-15T18:18:43.135Z</atom:updated>
            <content:encoded><![CDATA[<p>As a writer, I would write pieces of literature which would inspire others to do better than what they are. It doesn&#39;t necessarily have to inspire everyone under the sun. If even a single person relates and is inspired by it, I would be satisfied. These pieces of literature wouldn&#39;t, however, be utopian/ideal perspectives. Instead, it would be the personal bitter experiences and encounters.</p><p>At a given point in life, everyone deals with darkness, dilemma, confusion and frustration. As a writer and human being, I believe addressing these personal issues would reach them in times of need. It would reach them at a time when they are at their lowest, loneliest, at a point in time where they feel helpless and cannot approach anyone around them.</p><p>The objective of my writing would not be to give them the answers to all their questions. It is to let them know that even in their darkness, they aren’t alone. It is to provide them with a sense of relief and togetherness in a time where either seems to be scarce. Personally, it would feel like I have contributed back to society and find satisfaction in knowing that I have been able to provide a sense of calm to those in need.</p><p>People generally find solace in knowing that they’re not alone, and from that solace, beautiful relations with others going through similar situations may arise. And I feel that this is the beauty of humanity which I want to harness, a sense of togetherness and hope when there is none around.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ad7a1f17475" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sorting Techniques 1.0]]></title>
            <link>https://medium.com/spidernitt/sorting-techniques-1-0-20698642b2a5?source=rss-901017a6e34b------2</link>
            <guid isPermaLink="false">https://medium.com/p/20698642b2a5</guid>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[competitive-programming]]></category>
            <dc:creator><![CDATA[Richikghosh]]></dc:creator>
            <pubDate>Wed, 26 Jan 2022 08:51:28 GMT</pubDate>
            <atom:updated>2022-01-26T08:51:28.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1jNMyHdaU_VlW4GD.jpg" /></figure><p><em>Have you ever wondered how items on an online shopping website rearranges its items for sale to match your preferences (for example: Prices- Highest to Lowest)? What are the underlying algorithms? Let’s find out…</em></p><p><em>There are innumerable ways of “Sorting” so let’s check out some of the most popular sorting techniques!!</em></p><h3><strong><em>SORTING ALGORITHMS</em></strong></h3><p>Before we dive into the various types of sorting algorithms let’s first see what “Sorting” actually is and some basic terms related to it.</p><p><strong>Sorting is any process of arranging items systematically. </strong>It has two common, yet distinct meanings: Ordering (arranging items in a sequence ordered by some criterion) and Categorizing (grouping items with similar properties).</p><p>However, in coding, <strong>a Sorting Algorithm is used to rearrange a given array or list elements according to a comparison operator on the elements</strong>. The comparison operator is used to decide the new order of elements in the respective data structure.</p><p>Time Complexity — <strong>the amount of time taken by an algorithm to run</strong>, as a function of the length of the input. It measures the time taken to execute each statement of code in an algorithm.</p><p>Space Complexity — The space complexity of an algorithm or a computer program is <strong>the amount of memory space required to solve an instance of</strong> the computational problem as a function of the characteristics of the input. It is the memory required by an algorithm until it executes completely.</p><p>Algorithmic Paradigm — a generic model or framework which underlies the design of a class of algorithms. For example:- Divide and conquer, Brute force, Dynamic programming etc.</p><p>Stability — A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input array to be sorted.</p><h3>INSERTION SORT</h3><p>Chances are you have probably already heard of this sorting technique. Insertion sort is one of the most basic and most popular sorting techniques to exist.</p><p>Insertion sort uses the idea of dividing the array into two parts — the first part of the array being the ‘Sorted part’ and the remaining part being the ‘Unsorted Part’. The ‘Unsorted Part’ of the array is iterated through and each element is compared with the predecessor.|<br>If this element is greater than or equal to the predecessor no change is made and the iteration is continued.<br>If this element is smaller than the predecessor then the element is ‘inserted’ into the correct position of the ‘Sorted Part’ and then the iteration is continued.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*X78qSPfXtjwMzPmUvv_4nQ.png" /><figcaption>GREEN HIGHLIGHTED PORTION -&gt; Sorted Part; NON HIGHLIGHTED PORTION -&gt; Unsorted Part</figcaption></figure><p>The following is the python code for Insertion Sort :-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42172e5fee644abe844e4f53304a022b/href">https://medium.com/media/42172e5fee644abe844e4f53304a022b/href</a></iframe><p><strong>Time Complexity:</strong> O(n²) <br><strong>Space Complexity:</strong> O(1)<br><strong>Algorithmic Paradigm:</strong> Incremental Approach <em>(i.e to enable the user to visualise intermediate results until a desired final result is achieved)</em><br><strong>Stable:</strong> Yes</p><h3>COUNTING SORT</h3><p>Counting sort is a type of sorting algorithm used when the the range of the given data set is known. The idea behind implements counting the number of elements having distinct key values (kind of hashing). Then doing some arithmetic to calculate the position of each object in the output sequence.</p><p>To understand this let us see a quick example:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d89AxVx17ArhmCeYqQAFgw.jpeg" /></figure><p>The given data input is:- 1,4,1,2,7,5,2<br>We use a ‘count array’ to note the occurrences of each element in the data input at the element-index of the count array. Here, there are two 1s in the data input, hence the value 2 is stored at index 1 in the count array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*hW2U35QhuSGNhMOW_iNqGw.png" /></figure><p>We then modify the count array by adding the previous counts in the count array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*6WFRDfZvSOhEVKhi91cJZQ.png" /></figure><p>The final ‘output array’ is created. We now again parse the data input. For each element (k) in the data input, we see the value (v) at that index (k) in the count array. We place this element (k) at the index (v) of the output array and then decrease the value (v) in the count array by 1.</p><p>Here in this example:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I0SszJ_4Nty6zF9nx6Ep3w.png" /><figcaption><strong>Step 1</strong></figcaption></figure><p>1 -&gt; has a count of 2 -&gt; placed at index 2 in the output array (and count is decremented and changes to 1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mWImX36DotdbHwrmQCVphg.png" /><figcaption><strong>Step 2</strong></figcaption></figure><p>4 -&gt; has a count of 5-&gt; placed at index 5 in the output array (and the count is decremented and changed to 4)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nt5_j1OOQA7G0rtiDROnXg.png" /><figcaption><strong>Step 3</strong></figcaption></figure><p>1 -&gt; has a count of 1 (value changed from 2 to 1 at step 1)-&gt; placed at index 1 in the output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-SEXgNJXraR8SdYRUvDGg.png" /><figcaption><strong>Step 4</strong></figcaption></figure><p>2 -&gt; has a count of 4-&gt; placed at index 4 in the output array (and the count is decremented and changes to 3)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0v_yvaDTwxvBh2d9OJrig.png" /><figcaption><strong>Step 5</strong></figcaption></figure><p>7 -&gt; has a count of 7-&gt; placed at index 7 in the output array (and the count is decremented and changes to 6)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1M7FGnKlLWAhkye8y-2TOQ.png" /><figcaption><strong>Step 6</strong></figcaption></figure><p>5 -&gt;has a count of 6-&gt; placed at index 6 in the output array (and count is decremented and changes to 5)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*556aIWPqZsS7nt2OZKZn9g.png" /><figcaption><strong>Step 7</strong></figcaption></figure><p>2 -&gt; has a count of 3 (value changed from 4 to 3 at step 3)-&gt; placed at index 3 in the output array (and the count is decremented and changes to 2)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*upnBKYHg9fOvEoQC9-JsPw.png" /><figcaption><strong>The final status of each array that is taken for consideration after the data set is sorted</strong></figcaption></figure><p>Above is the given image of the final status of output and count arrays.</p><p>The following is the python code for Counting Sort:-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/deb35ba91989db41a6d8b464e5c84944/href">https://medium.com/media/deb35ba91989db41a6d8b464e5c84944/href</a></iframe><p><strong>Time Complexity:</strong> O(n+k) <em>where n is the number of elements in the input array and k is the range of input.</em><br><strong>Auxiliary Space:</strong> O(n+k)<br><strong>Stable:</strong> Yes</p><h3>RADIX SORT</h3><p>Now that we have seen Counting sort what happens if we have huge ranges of numbers? Using counting sort would take too much time to sort large data sets. And that brings us to our next sorting method -&gt; Radix Sort. Radix sort implements the idea of sorting by the digits of the numbers, starting from the least significant digit to the most significant digit.</p><p>Let’s try to understand this with an example:-</p><pre>Given data input:-<br>23, 7, 439, 129, 366, 47, 256, 69</pre><pre>We start from the least significant digit:-<br>2<strong><em>3</em></strong>, <strong><em>7</em></strong>, 43<strong><em>9</em></strong>, 12<strong><em>9</em></strong>, 36<strong><em>6</em></strong>, 4<strong><em>7</em></strong>, 8<strong><em>6</em></strong>, 6<strong><em>9 </em></strong>-&gt; 2<strong><em>3</em></strong>, 36<strong><em>6</em></strong>, 8<strong><em>6</em></strong>, <strong><em>7</em></strong>, 4<strong><em>7</em></strong>, 43<strong><em>9</em></strong>, 12<strong><em>9</em></strong>, 6<strong><em>9</em></strong></pre><pre>We move to the next significant digit:-<br><strong><em>2</em></strong>3, 3<strong><em>6</em></strong>6, <strong><em>8</em></strong>6, 7, <strong><em>4</em></strong>7, 4<strong><em>3</em></strong>9, 1<strong><em>2</em></strong>9, <strong><em>6</em></strong>9 -&gt; 7, <strong><em>2</em></strong>3, 4<strong><em>3</em></strong>9, 1<strong><em>2</em></strong>9, <strong><em>4</em></strong>7, 3<strong><em>6</em></strong>6, <strong><em>6</em></strong>9, <strong><em>8</em></strong>6</pre><pre>We move to the next significant digit:-<br>7, 23, <strong><em>4</em></strong>39, <strong><em>1</em></strong>29, 47, <strong><em>3</em></strong>66, 69, 86 -&gt; 7, 23, 47, 69, 86, <strong><em>1</em></strong>29, <strong><em>3</em></strong>66, <strong><em>4</em></strong>39</pre><pre>Final sorted output:- <br>7, 23, 47, 69, 86, 129, 366, 439</pre><p>The following is the python code for Radix Sort:-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ea05c6ff19cc3dc1baa9e481021e7c7/href">https://medium.com/media/7ea05c6ff19cc3dc1baa9e481021e7c7/href</a></iframe><p><strong>Time Complexity:</strong>O((n+b) * logb(k)) <em>where n is the number of elements in the input array, b is the base of the number system and k is the maximum input.</em><br><strong>Auxiliary Space:</strong> O(n+2^d)<br><strong>Stable:</strong> Yes</p><h3>A FEW POPULAR SORTING TECHNIQUES</h3><p><strong><em>Bubble Sort</em></strong> is a very popular sorting technique and is one of the most basic sorting algorithms everyone usually starts off with. The algorithm works by repeatedly swapping the adjacent elements if they are in the wrong order.<br>Let us see the following example:-</p><pre><strong>Given Data Input :- </strong>( 5 1 4 2 8 )<strong><br>First Pass:</strong> <br>( <strong>5</strong> <strong>1</strong> 4 2 8 ) –&gt; ( <strong>1</strong> <strong>5</strong> 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 &gt; 1. <br>( 1 <strong>5</strong> <strong>4</strong> 2 8 ) –&gt;  ( 1 <strong>4</strong> <strong>5</strong> 2 8 ), Swap since 5 &gt; 4 <br>( 1 4 <strong>5</strong> <strong>2</strong> 8 ) –&gt;  ( 1 4 <strong>2</strong> <strong>5</strong> 8 ), Swap since 5 &gt; 2 <br>( 1 4 2 <strong>5</strong> <strong>8</strong> ) –&gt; ( 1 4 2 <strong>5</strong> <strong>8</strong> ), Now, since these elements are already in order (8 &gt; 5), algorithm does not swap them.<br><strong>Second Pass:</strong> <br>( <strong>1</strong> <strong>4</strong> 2 5 8 ) –&gt; ( <strong>1</strong> <strong>4</strong> 2 5 8 ) <br>( 1 <strong>4</strong> <strong>2</strong> 5 8 ) –&gt; ( 1 <strong>2</strong> <strong>4</strong> 5 8 ), Swap since 4 &gt; 2<br>( 1 2 <strong>4</strong> <strong>5</strong> 8 ) –&gt; ( 1 2 <strong>4</strong> <strong>5</strong> 8 ) <br>( 1 2 4 <strong>5</strong> <strong>8</strong> ) –&gt;  ( 1 2 4 <strong>5</strong> <strong>8</strong> ) <br>Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one <strong>whole</strong> pass without <strong>any</strong> swap to know it is sorted.<br><strong>Third Pass:</strong> <br>( <strong>1</strong> <strong>2</strong> 4 5 8 ) –&gt; ( <strong>1</strong> <strong>2</strong> 4 5 8 ) <br>( 1 <strong>2</strong> <strong>4</strong> 5 8 ) –&gt; ( 1 <strong>2</strong> <strong>4</strong> 5 8 ) <br>( 1 2 <strong>4</strong> <strong>5</strong> 8 ) –&gt; ( 1 2 <strong>4</strong> <strong>5</strong> 8 ) <br>( 1 2 4 <strong>5</strong> <strong>8</strong> ) –&gt; ( 1 2 4 <strong>5</strong> <strong>8</strong> )</pre><p>The<strong><em> Selection sort</em></strong><em> </em>algorithm<em> </em>sorts an array by repeatedly finding the minimum element (considering ascending order) from the unsorted part and putting it at the beginning. The algorithm maintains two subarrays in a given array.<br>1) The already sorted subarray <br>2) The remaining unsorted subarray<br>In every iteration of selection sort, the minimum element (considering ascending order) from the unsorted subarray is picked and moved to the sorted subarray. <br>The following example explains the above steps:</p><pre>arr[] = 64 25 12 22 11<br><br>// Find the minimum element in arr[0...4]<br>// and place it at beginning<br><strong>11 </strong>25 12 22 64<br><br>// Find the minimum element in arr[1...4]<br>// and place it at beginning of arr[1...4]<br>11 <strong>12 </strong>25 22 64<br><br>// Find the minimum element in arr[2...4]<br>// and place it at beginning of arr[2...4]<br>11 12 <strong>22 </strong>25 64<br><br>// Find the minimum element in arr[3...4]<br>// and place it at beginning of arr[3...4]<br>11 12 22 <strong>25 </strong>64</pre><h3><strong>CONCLUSION</strong></h3><p>Sorting Algorithms/Techniques are very helpful to sort the given data at your convenience. It is very helpful for competitive programming. You can parse data structures and order them much faster and very easily.</p><p>Learning how to sort data structures is very useful but not always easy to perform. This article covers only a few sorting algorithms. Stay tuned in for more on Sorting Algorithms/Techniques.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F7603564&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fprogrammer-programming-computer-typing-gif-7603564&amp;image=https%3A%2F%2Fc.tenor.com%2F41I-iMyClCgAAAAd%2Fprogrammer-programming.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/696cb7b8553e942bec3a9dbd1f9f5d06/href">https://medium.com/media/696cb7b8553e942bec3a9dbd1f9f5d06/href</a></iframe><h3>REFERENCES</h3><p>Code:- GeeksForGeeks, Programiz<br>Pictures:- GeeksForGeeks and Google Images</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20698642b2a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/spidernitt/sorting-techniques-1-0-20698642b2a5">Sorting Techniques 1.0</a> was originally published in <a href="https://medium.com/spidernitt">Spider R&amp;D</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>