<?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: jeromecaisip</title>
    <description>The latest articles on DEV Community by jeromecaisip (@jeromecaisip).</description>
    <link>https://dev.to/jeromecaisip</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%2F150331%2F7a65be03-bf18-4589-bb48-8d1c0e454028.jpeg</url>
      <title>DEV Community: jeromecaisip</title>
      <link>https://dev.to/jeromecaisip</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeromecaisip"/>
    <language>en</language>
    <item>
      <title>How I Learned The Intuition Behind Recursion</title>
      <dc:creator>jeromecaisip</dc:creator>
      <pubDate>Tue, 02 Feb 2021 05:39:44 +0000</pubDate>
      <link>https://dev.to/jeromecaisip/how-i-learned-the-intuition-behind-recursion-1bc2</link>
      <guid>https://dev.to/jeromecaisip/how-i-learned-the-intuition-behind-recursion-1bc2</guid>
      <description>&lt;p&gt;When I was studying data structures and algorithms, I did some exercise implementing BST(binary search tree) and its operations.&lt;/p&gt;

&lt;p&gt;I was able to implement &lt;code&gt;insert&lt;/code&gt; and &lt;code&gt;search&lt;/code&gt; using iteration because it's more intuitive for me compared to using recursion, until I have to work on the &lt;code&gt;delete&lt;/code&gt; operation, specifically on the case where the node I need to delete has 2 children. For context, in order to this, I had to identify the left most node of the right subtree and use its value to replace the value of the node I intend delete.&lt;/p&gt;

&lt;p&gt;Using iteration looks easy for BST with a height of 2 or 3 even. However, as I was trying to test it on cases wherein the height of tree is 4 or greater, the code got complicated. So I reset my thoughts, then looked at the problem in a different perspective, then it hit me! A node of a BST is a BST itself! And this applies to linked-lists and array as well, a node of a linked-list is a linked-list, an index of an array is an array.&lt;/p&gt;

&lt;p&gt;Then I suddenly remember what Prof.Skiena said, from a reader of his book, on one of his lectures about building a mental model for recursion. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you take a bite out of a salad, you get a smaller salad. But if you took a bite from a hamburger, you don't get a smaller hamburger. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Here's the output of my work:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


</description>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
