<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jason Mishike</title>
    <description>The latest articles on DEV Community by Jason Mishike (@jasonmishi).</description>
    <link>https://dev.to/jasonmishi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F886427%2Ffffbebe5-c726-4024-addd-2546b27e34e4.jpeg</url>
      <title>DEV Community: Jason Mishike</title>
      <link>https://dev.to/jasonmishi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jasonmishi"/>
    <language>en</language>
    <item>
      <title>Recommitting to this blog</title>
      <dc:creator>Jason Mishike</dc:creator>
      <pubDate>Thu, 14 Sep 2023 17:19:03 +0000</pubDate>
      <link>https://dev.to/jasonmishi/recommitting-to-this-blog-kja</link>
      <guid>https://dev.to/jasonmishi/recommitting-to-this-blog-kja</guid>
      <description>&lt;p&gt;I am going to attempt to write more in this blog. I'm not sure what I'll write about but I think writing more is beneficial.&lt;/p&gt;

&lt;p&gt;Writing helps me refine my thoughts. It's easy to jump from thought to thought in your head. You can't jump away from words on a page, or a screen, the same way; they provide a anchor that shows you what you were last thinking about. Without that anchor its easy to get swept away and never return to the actual point of your initial thought.&lt;/p&gt;

&lt;p&gt;Whatever I do decide to write on I want to keep as human as possible. Generative AI is interesting and I would never have expected it to come as far as it has, but I'm writing to better understand my thoughts, not to understand how an AI model processes prompts. That being said, I might use some phrasing or interesting structure from the AI, but I will always absorb it and write it down myself. However I find that I don't like the writing style of AI, it seems to generate a lot of fluff with little substance. &lt;/p&gt;

&lt;p&gt;I used to be scared of writing and publishing articles as I felt that there is a chance of being dreadfully wrong, this is a natural feeling to have. However, I have realized, that being wrong is an opportunity to better myself. (I would say I'm only human, but I've been lied to by GPT-4 and copilot so many times I'm not going to). So here is to this post, hopefully the first of many.&lt;/p&gt;

&lt;p&gt;P.S. I learnt today that the 12th of September was Programmer's day, so happy programmers day! Fun Fact: Programmer's day can alternate between the 12th and 13th depending on whether it is a leap year or not.&lt;/p&gt;

</description>
      <category>writing</category>
      <category>learning</category>
    </item>
    <item>
      <title>Bubble Sort vs Insertion Sort vs Selection Sort: When and why to use what?</title>
      <dc:creator>Jason Mishike</dc:creator>
      <pubDate>Wed, 21 Sep 2022 15:06:57 +0000</pubDate>
      <link>https://dev.to/jasonmishi/bubble-sort-vs-insertion-sort-vs-selection-sort-when-and-why-to-use-what-49bd</link>
      <guid>https://dev.to/jasonmishi/bubble-sort-vs-insertion-sort-vs-selection-sort-when-and-why-to-use-what-49bd</guid>
      <description>&lt;p&gt;(This might seem like a simple topic that is unimportant (most of us probably just use .sort()) but relearning and diving into the nitty-gritty in university was some food for thought and I decided to share that meal.)&lt;/p&gt;

&lt;p&gt;On one corner a master of the shuffle, a fighter who keeps things simple but gets the job done, BUBBLE SORT! On the other corner a fighter who is often compared to the Recursives, if he smells weakness he will end it quickly, hailing from stable town here's INSERTION SORT! And on the other(other) corner a fighter who likes to take his time and throw the same punches no matter who he faces, with an battle tested formula and a simple plan here is SELECTION SORT! Let the battle (that one of my lecturers asked for) begin! DING! DING! DING!&lt;br&gt;
&lt;em&gt;This post will mainly deal with when to use what and how they compare against each other. There will be a quick refresher on how they work but if you want implementation details you'll have to look somewhere else.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Refresher
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Bubble Sort
&lt;/h3&gt;

&lt;p&gt;The easiest to remember in my opinion, compare values next to each other, if they are not in order, swap, repeat until sorted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y49pbC-i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vu5qczp6s1nc0farfliu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y49pbC-i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vu5qczp6s1nc0farfliu.png" alt="Diagram illustrating Bubble Sort" width="336" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Insertion Sort
&lt;/h3&gt;

&lt;p&gt;In this algorithm there is a sorted sub-array(or section) and an unsorted one, elements of the unsorted sub-array are inserted into their proper place in the sorted side one by one (by comparing from highest to lowest in the sorted sub-array).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--csmz_Gzx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8iyicqo24soyjr7psnf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--csmz_Gzx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l8iyicqo24soyjr7psnf.png" alt="Diagram illustrating Insertion Sort" width="369" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Selection Sort
&lt;/h3&gt;

&lt;p&gt;In selection sort you find the lowest value and swap it with the value in the first spot, find the second-lowest and swap it with the value in the second spot, third-lowest to third spot so on until the last element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Xp0MNCav--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bi3pd7zvx5n7t5w0tl47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xp0MNCav--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bi3pd7zvx5n7t5w0tl47.png" alt="Diagram illustrating Selection Sort" width="339" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Head to Head
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Stability
&lt;/h3&gt;

&lt;p&gt;A sorting algorithm is stable if equal values do not lose their original order when sorted. Illustrated for clarity in the diagram below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--17TTZxfR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/slx70nur44bgrri9nyq0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--17TTZxfR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/slx70nur44bgrri9nyq0.png" alt="Diagram illustrating stability" width="322" height="126"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Both Bubble Sort and Insertion Sort are stable, but Selection is not. This is because the order might be jumbled when swapping, as such:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I6TP1vxZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/igtdylgqzstkfhk9dgov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I6TP1vxZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/igtdylgqzstkfhk9dgov.png" alt="Diagram showing why selection sort is not stable" width="323" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whether or not you need stability depends on your use-case.&lt;/p&gt;

&lt;h3&gt;
  
  
  Complexity - The Main Event
&lt;/h3&gt;

&lt;p&gt;This is where the winners and losers are decided. If stability is not a constraint who do you hedge your bets on? There are 2 main measures that determine which is the most (theoretically?) efficient algorithm, comparison and writing complexity.&lt;/p&gt;

&lt;h4&gt;
  
  
  Comparisons
&lt;/h4&gt;

&lt;p&gt;All the contending algorithms have a worst and average-case comparison complexity of O(n&lt;sup&gt;2&lt;/sup&gt;). Bubble and Insertion Sort has a best-case comparison complexity of O(n) while Selection Sort's best-case is the same as it's worst case at O(n&lt;sup&gt;2&lt;/sup&gt;).&lt;br&gt;
Why is this? If the elements are already or nearly sorted Bubble Sort and Insertion Sort will require less comparisons (Might be helpful to dry run the algorithms with sorted or nearly sorted arrays). This is not the case for Selection Sort where the algorithm doesn't(or can't) care whether elements are already in order, and will treat all elements as unordered.&lt;/p&gt;

&lt;h4&gt;
  
  
  Writes
&lt;/h4&gt;

&lt;p&gt;Selection sort has a best, average and worst case complexity of O(n) for writes(or swaps), again this is because the algorithm doesn't(or can't) care if elements are in their proper place already. Insertion and Bubble sort have a best case complexity of O(1), average case of O(n&lt;sup&gt;2&lt;/sup&gt;) and a worst case of O(n&lt;sup&gt;2&lt;/sup&gt;) but due to the nature of the algorithm, bubble sort needs around twice the amount of writes as insertion sort in practice (multipliers are not counted in complexity).&lt;/p&gt;

&lt;h4&gt;
  
  
  Summary (worst case, average case, best case)
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Comparisons&lt;/strong&gt;&lt;br&gt;
Bubble Sort: O(n&lt;sup&gt;2&lt;/sup&gt;), O(n&lt;sup&gt;2&lt;/sup&gt;), O(n)&lt;br&gt;
Selection Sort: O(n&lt;sup&gt;2&lt;/sup&gt;), O(n&lt;sup&gt;2&lt;/sup&gt;), O(n&lt;sup&gt;2&lt;/sup&gt;),&lt;br&gt;
Insertion Sort: O(n&lt;sup&gt;2&lt;/sup&gt;), O(n&lt;sup&gt;2&lt;/sup&gt;), O(n)&lt;br&gt;
&lt;strong&gt;Writes&lt;/strong&gt;&lt;br&gt;
Bubble Sort: O(n&lt;sup&gt;2&lt;/sup&gt;), O(n&lt;sup&gt;2&lt;/sup&gt;), O(1)&lt;br&gt;
Selection Sort: O(n), O(n), O(n)&lt;br&gt;
Insertion Sort: O(n&lt;sup&gt;2&lt;/sup&gt;), O(n&lt;sup&gt;2&lt;/sup&gt;), O(1)&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to use what
&lt;/h2&gt;

&lt;p&gt;Insertion sort is to be used in most places because it is likely the list will be partially sorted and depending on the situation stability might be required.&lt;br&gt;
But you can use Selection sort if you want to reduce the amount of writes and you don't need the algorithm to be stable.&lt;br&gt;
But what about Bubble sort?&lt;/p&gt;

&lt;h3&gt;
  
  
  Is it time for Bubble Sort to retire? :(
&lt;/h3&gt;

&lt;p&gt;It is a very popular sorting algorithm and the first one I learnt in school. This is because it is easy to teach and somewhat more "interesting" that selection sort in my opinion. However people have started to advocate to stop teaching this as Insertion sort works better in nearly all cases. Donald Knuth wrote in The Art of Computer Programming, that "the bubble sort seems to have nothing to recommend it, except a catchy name and the fact that it leads to some interesting theoretical problems". Oof. I don't see any disagreement but I did like learning about it even though that might be my nostalgia glasses blurring my mind's eye. &lt;/p&gt;

&lt;p&gt;What do you think about bubble sort? Should it be retired, or does it serve a purpose?&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>performance</category>
    </item>
    <item>
      <title>Entanglement isn't thaaat spooky - The shoe-box analogy</title>
      <dc:creator>Jason Mishike</dc:creator>
      <pubDate>Sun, 17 Jul 2022 10:36:14 +0000</pubDate>
      <link>https://dev.to/jasonmishi/entanglement-isnt-thaaat-spooky-the-shoe-box-analogy-238j</link>
      <guid>https://dev.to/jasonmishi/entanglement-isnt-thaaat-spooky-the-shoe-box-analogy-238j</guid>
      <description>&lt;p&gt;I had to do a bit of research in basic Quantum Computing, when reading about "spooky action at a distance" or entanglement I was intrigued, I though this could be used to transfer information over distances, this seems to be a common misconception, you can read &lt;a href="https://www.forbes.com/sites/startswithabang/2020/01/02/no-we-still-cant-use-quantum-entanglement-to-communicate-faster-than-light/?sh=7807b71b4d5d"&gt;this Forbes article&lt;/a&gt; by a Ph.D. astrophysicist to understand why it doesn't work in detail, but I found a helpful analogy. It goes like this.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Entanglement shoe-box analogy
&lt;/h2&gt;

&lt;p&gt;Assume you have a shoe-box, one of the shoes has been taken and placed at the end of the universe. When you open the shoe-box you observe you have the right shoe, that means the shoe at the other end of the universe is the left one(assuming a normal shoe box). This is how entanglement works. Changing the shoe in the shoe-box in any way has no effect on the shoe that's on the end of the universe, you see the shoe you get the information and that is it. In the article it's said that forcing a state (changing the shoe) would break the entanglement. It is also stated on entanglement that "You know something important about the sum of both states together", or in the shoe-box you know that it should contain both a left and right shoe(normally). :)&lt;/p&gt;

</description>
      <category>quantumcomputing</category>
      <category>todayilearned</category>
      <category>quantummechanics</category>
    </item>
  </channel>
</rss>
