<?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: Khalil Saboor</title>
    <description>The latest articles on DEV Community by Khalil Saboor (@khalilsaboor).</description>
    <link>https://dev.to/khalilsaboor</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%2F20017%2F7f947917-7c06-4417-acc9-79203431840d.png</url>
      <title>DEV Community: Khalil Saboor</title>
      <link>https://dev.to/khalilsaboor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khalilsaboor"/>
    <language>en</language>
    <item>
      <title>Fibonacci: Recursion vs Iteration</title>
      <dc:creator>Khalil Saboor</dc:creator>
      <pubDate>Thu, 08 Nov 2018 00:55:10 +0000</pubDate>
      <link>https://dev.to/khalilsaboor/fibonacci-recursion-vs-iteration--474l</link>
      <guid>https://dev.to/khalilsaboor/fibonacci-recursion-vs-iteration--474l</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fix7q2y5scx1more6hy0o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fix7q2y5scx1more6hy0o.jpg" alt="Alt:" width="800" height="668"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A common whiteboard problem that I have been asked to solve couple times, has been to &lt;strong&gt;"write a function to generate the nth Fibonacci number starting from 0,1"&lt;/strong&gt;. In this post, however, I want to address a common follow up question for this problem and that is what method is more efficient for solving this problem Recursion or Iteration.&lt;/p&gt;

&lt;h1&gt;
  
  
  NOTE
&lt;/h1&gt;

&lt;p&gt;It best practice to always attempt this problem before reading further into the article. So I listed out a few common tools for completing this problem.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pen/Marker&lt;/li&gt;
&lt;li&gt;Notebook/WhiteBoard&lt;/li&gt;
&lt;li&gt;VS Code&lt;/li&gt;
&lt;li&gt;The Internet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Fibonacci numbers are a sequence of integers in&lt;br&gt;
which the first two elements are 0 &amp;amp; 1, and each following&lt;br&gt;
elements are the sum of the two preceding elements:&lt;/p&gt;

&lt;p&gt;0, 1,  1,  2,  3,  5,  8,  13,  21,  34,  55,  89,  144, ..., 233&lt;/p&gt;

&lt;h1&gt;
  
  
  The Problem
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Write a function to generate the nth Fibonacci number.&lt;br&gt;
The nth Fibonacci number is given by:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fn = Fn-1 + Fn-2
The first two terms of the series are 0, 1.
For example: fib(0) = 0, fib(1) = 1, fib(2) = 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h1&gt;
  
  
  Solution #1 Using Recursion
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;fibonacciRecursion&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;nthNumber&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;//use recursion&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nthNumber&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nthNumber&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;   
     &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;fibonacciRecursion&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nthNumber&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;fibonacciRecursion&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nthNumber&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Analysis
&lt;/h1&gt;

&lt;p&gt;By using Recursion to solve this problem we get a cleanly written function, that checks. If the given number is equal to 0 and 1 we return both given numbers. &lt;/p&gt;

&lt;p&gt;If we pass a number that is greater than 0 and 1. Then we make two recursive calls where we add both calls with the nthNumber minus 1 and 2 in both calls.&lt;/p&gt;

&lt;p&gt;Passing these Integers 0, 1, 2, 3, 4, 5, Will most likely give us --&amp;gt; 0, 1, 1, 2, 3, 5 in a timely fashion. &lt;/p&gt;

&lt;p&gt;But what happens if we pass higher numbers like 50, 67, 100. Well if you try to run the function with the given numbers in you're IDE. You will begin to notice how much longer it takes for this method gives us our Fibonacci number. Now trying to run a Space Complexity analysis will be a tricky thing to do because of a lot of things are happening behind the scenes of this recursive function. The reason for the poor performance is heavy push-pop of the stack memory in each recursive call.&lt;/p&gt;

&lt;p&gt;Now for a way around this would be using memorization and storing each Fibonacci calculated so. But for now, I'm going to move along to the Iteration method and why it would compute our 100th Fibonacci number faster.&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution #2 Using Iteration
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;
 &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;fibonacciLoop&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;nthNumber&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;//use loop&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;previouspreviousNumber&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;previousNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;currentNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;nthNumber&lt;/span&gt; &lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

            &lt;span class="n"&gt;previouspreviousNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;previousNumber&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

            &lt;span class="n"&gt;previousNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;currentNumber&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

            &lt;span class="n"&gt;currentNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;previouspreviousNumber&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;previousNumber&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="o"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;currentNumber&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Analysis
&lt;/h1&gt;

&lt;p&gt;The Iteration method would be the prefer and faster approach to solving our problem because we are storing the first two of our Fibonacci numbers in two variables (previouspreviousNumber, previousNumber) and using "CurrentNumber" to store our Fibonacci number. Storing these values prevent us from constantly using memory space in the Stack. Thus giving us a time complexity of O(n).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/java-vault/java-memory-allocation-stack-and-heap-3e25867baa7e" rel="noopener noreferrer"&gt;For more information on Stack and Heap memory in the context of Java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=vYquumk4nWw&amp;amp;t=23s" rel="noopener noreferrer"&gt;For more information on Dynamic programming approach&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>algorithms</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How should I go about creating a portfolio site?</title>
      <dc:creator>Khalil Saboor</dc:creator>
      <pubDate>Sat, 20 Oct 2018 00:48:14 +0000</pubDate>
      <link>https://dev.to/khalilsaboor/how-should-i-go-about-creating-a-portfolio-site-5366</link>
      <guid>https://dev.to/khalilsaboor/how-should-i-go-about-creating-a-portfolio-site-5366</guid>
      <description>&lt;p&gt;Hey Guys, I wanted to know if I could get some pointers on going about creating my first Portfolio site. I'm open to videos, posts, and example portfolio sites.&lt;/p&gt;

&lt;p&gt;A little about me: I'm mostly a Back-End Developer (Java) (little Python/Go) with a repo of Console applications, Two SpringBoot App and a few Front-End projects. I have a Basic background of Front-End tools like HTML, CSS, and JS from the old Free Code Camp site.&lt;/p&gt;

&lt;p&gt;One of the main things I wanted to know is if I should use a framework like React or Vue.JS or write it basic HTML, CSS, and JS as a single page? Also, I found a tutorial where a guy walks through creating a modern Portfolio site (Traversy Media no Framework ). But I feel like it would be checking to just follow along and create it. &lt;/p&gt;

</description>
      <category>discuss</category>
      <category>help</category>
      <category>beginners</category>
      <category>learning</category>
    </item>
    <item>
      <title>Great questions for YOU to ask during a Technical Interview</title>
      <dc:creator>Khalil Saboor</dc:creator>
      <pubDate>Tue, 16 Oct 2018 20:41:23 +0000</pubDate>
      <link>https://dev.to/khalilsaboor/great-questions-for-you-to-ask-during-a-techincal-interview-5a9p</link>
      <guid>https://dev.to/khalilsaboor/great-questions-for-you-to-ask-during-a-techincal-interview-5a9p</guid>
      <description>&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;As someone who has bomb their first 6 technical interviews. I as feel as though I should write about my experiences and inform the masses about what they should know before heading into a technical interview.&lt;/p&gt;

&lt;p&gt;While I did sort them into HR and Dev. I have had in my experience ask both Hiring managers and Developers question on either pool these questions. Also, It's best to not assume your Hiring manager is not technical. You'll be surprised what are their response is to the questions I have listed for Developers. &lt;/p&gt;

&lt;h1&gt;
  
  
  For Hiring Managers
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Do you have a business card?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What are the career growth opportunities for someone in this position?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How does [company name] help developers stay in sync with current technologies?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is the most impactful thing I could do starting out at [company name]?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What does the onboarding process look like for new candidates?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  For Developer/Lead/managers
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;What do you enjoy most about working at [company name]?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Could you tell me your team technical stack?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What does the average day look like for you?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What will my role be during the first couple of months at [company name]?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What performance metrics do you use to determine a successful ticket/feature is completes?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can you tell me a recent project or feature you that you feel proud?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Quick intro about myself:
&lt;/h1&gt;

&lt;p&gt;I have been learning how to become a Software Developer for roughly 4 years now. A large part of my learning has been self-taught w/Free Code Camp and Youtube. I just recently graduated from a 12 week Java base Coding BootCamp called Zip Code Wilmington. But I have had knowledge of Java and Computer Programming since High School. I'm currently mentoring someone in JavaScript and Front-End Development using the same Free Code Camp and Codecademy. I've planned on writing some more post my prior experiences on technical interviews. &lt;/p&gt;

</description>
      <category>advice</category>
      <category>interview</category>
      <category>career</category>
    </item>
    <item>
      <title>Hi, I'm Khalil Saboor</title>
      <dc:creator>Khalil Saboor</dc:creator>
      <pubDate>Sun, 28 May 2017 00:00:43 +0000</pubDate>
      <link>https://dev.to/khalilsaboor/hi-im-khalil-saboor</link>
      <guid>https://dev.to/khalilsaboor/hi-im-khalil-saboor</guid>
      <description>&lt;p&gt;I have been coding for 3 years.&lt;/p&gt;

&lt;p&gt;You can find me on Twitter as &lt;a href="https://twitter.com/justcallme_lil" rel="noopener noreferrer"&gt;@justcallme_lil&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I live in Philadelphia.&lt;/p&gt;

&lt;p&gt;I work for No Company as of now&lt;/p&gt;

&lt;p&gt;I mostly program in these languages: HTML, CSS, Js.&lt;/p&gt;

&lt;p&gt;I am currently learning more about Front-End and Swift.&lt;/p&gt;

&lt;p&gt;Nice to meet you.&lt;/p&gt;

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