<?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: Chidera</title>
    <description>The latest articles on DEV Community by Chidera (@jeni).</description>
    <link>https://dev.to/jeni</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%2F289425%2F5e96786a-07f4-40ee-9721-7143b9395e8c.jpeg</url>
      <title>DEV Community: Chidera</title>
      <link>https://dev.to/jeni</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeni"/>
    <language>en</language>
    <item>
      <title>Getting into Google - My Path</title>
      <dc:creator>Chidera</dc:creator>
      <pubDate>Sat, 17 Apr 2021 12:15:28 +0000</pubDate>
      <link>https://dev.to/jeni/getting-into-google-my-path-4fg1</link>
      <guid>https://dev.to/jeni/getting-into-google-my-path-4fg1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Sharing my story and process for others who would come after me.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A year ago, I got an invite to interview at Google. Although I was uncertain whether I would get in or not, I decided to “enjoy the process”.  &lt;/p&gt;

&lt;p&gt;I’d like to share that process with you, starting from my pre-interview to interviewing to post-interviewing with one of the mega-tech companies in the world, Google.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_84C1562A2B93BB8E847E7E856641C2ECCE98A397F8661D3084803862F720B3EF_1600802928923_Screenshot%2B2020-09-22%2Bat%2B20.20.08.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_84C1562A2B93BB8E847E7E856641C2ECCE98A397F8661D3084803862F720B3EF_1600802928923_Screenshot%2B2020-09-22%2Bat%2B20.20.08.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My path to Google was one that started unintentionally during my university days. Let’s go back in time for a bit to the beginning of my programming career:&lt;/p&gt;

&lt;p&gt;A few years ago, during my pre-university days, I developed interest in Software Development. I’d decided to try out a course on &lt;a href="https://coursera.org" rel="noopener noreferrer"&gt;Coursera&lt;/a&gt;. This course further increased my fascination after I successfully built a mini pingpong game using python. I marvelled at the power of the algorithms. The calculations, the motion of the pads, the balls rebounding on the pads at a tangent, all of which I had programmed.&lt;/p&gt;

&lt;p&gt;From there, I started learning more and more about algorithms, problem solving. It turned into a hobby of sorts. I solved a lot of questions on &lt;a href="https://hackerrank.com" rel="noopener noreferrer"&gt;Hackerrank&lt;/a&gt;. I didn’t pay much attention to what I was doing as it was all just a hobby, I really didn’t think much of the trajectory it was projecting my life.&lt;/p&gt;

&lt;p&gt;In 2018, during my internship at &lt;a href="https://genesystechhub.com" rel="noopener noreferrer"&gt;Genesys Tech Hub&lt;/a&gt; where I was having fun learning about Software Development using Nodejs, I was invited for a tech meet-up by a friend. It turned out not to be a talk meet-up, but rather an algorithm competition. Well, although we were late, I decided to attempt. I mean, why not? and guess what?&lt;/p&gt;

&lt;p&gt;I took the second place, despite being late and the only female contestant. It was both a shocking and proud moment for me and everyone there. This gave me the much needed motivation and boost to keep on practicing my algorithms some more.&lt;/p&gt;

&lt;p&gt;Consequently, I participated in some more competitions, winning some, losing most 😅 .&lt;/p&gt;

&lt;p&gt;One of those competitions I partook in was the “&lt;a href="https://codingcompetitions.withgoogle.com" rel="noopener noreferrer"&gt;CodeJam to I/O for Women&lt;/a&gt;” competition, in which the top 150 on the scoreboard will receive a ticket and reimbursement to offset travel expenses to Google I/O 2020.&lt;/p&gt;

&lt;p&gt;It was a tough competition. 2.5 hours of trying to crack the questions before some other 1000 people. At some point, I knew I wasn’t solving to get to the top 150. I was simply solving because I wanted to try and figure out the solutions to those problems. Sadly, not one problem was solved by me 😭 .&lt;/p&gt;

&lt;p&gt;I was really sad and wanted to quit. But thank Heavens for my friend (I have great friends) who motivated to keep on doing what I love.&lt;/p&gt;

&lt;p&gt;A few months later, I got an email from a recruiter at Google!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/113vTRXlcPoi8o/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/113vTRXlcPoi8o/giphy.gif" alt="via Giphy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It was exciting and unexpected. My recruiter had seen my email from the Google I/O competition attempt, checked out my LinkedIn &lt;a href="https://www.linkedin.com/in/chidera-olibie/" rel="noopener noreferrer"&gt;profile&lt;/a&gt; and had thought I might be a great fit for Google (and she was right, I am! Lol).&lt;/p&gt;

&lt;p&gt;We scheduled a preliminary call where she explained the interview process, the role I would be interviewing for and what was required. She’d mentioned there would be a technical phone interview which was the first stage (easy-medium questions), followed by 4 other onsite technical interviews (medium-hard questions) and 1 behavioural session. Knowing I was not fully prepared for a technical interview as a Software Engineer at Google, I informed her that I was not ready and asked if I could reach out to her later on, after I felt prepared (or at least a bit). She was cool with it and sent me some preparation materials and I got to work.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Do not rush the process.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It was crazy. I would stay up till 3am taking courses on the basics of Data Structures and Algorithms (links below), doing each and every assignment associated with it and reading algorithm books. &lt;/p&gt;

&lt;p&gt;I incorporated algorithms challenges specifically targeted at Google into my schedule, solving at least 2 per day on &lt;a href="https://leetcode.com/discuss/interview-question/352460/Google-Online-Assessment-Questions" rel="noopener noreferrer"&gt;Leetcode&lt;/a&gt; . In addition to that, I scheduled practice interview sessions on &lt;a href="//www.pramp.com"&gt;Pramp&lt;/a&gt; each day to familiarize myself with interview scenarios.&lt;/p&gt;

&lt;p&gt;A few months later, after I felt that I'd learnt enough, I reached out to her (my recruiter) and asked for an interview to be scheduled. &lt;/p&gt;

&lt;h2&gt;
  
  
  Phone Interview
&lt;/h2&gt;

&lt;p&gt;The phone interview was scheduled.&lt;/p&gt;

&lt;p&gt;The first stage of the technical interviewing process. Filled with courage and encouragement from my family, friends and social media peeps, I went in to &lt;strong&gt;wow&lt;/strong&gt; and &lt;strong&gt;wow&lt;/strong&gt; I did.&lt;/p&gt;

&lt;p&gt;The interview started with the interviewer’s introduction and calming opening speech, you know, the one where you are encouraged to relax and view the interview as a conversation between you and a teammate. Then I introduced myself, much more calmer and confident.&lt;/p&gt;

&lt;p&gt;Then the question came, and filled with glee at my realisation that I could figure out the solution, I proceeded to solve the question, speaking my mind and explaining my every step to the interviewer as though I were helping a teammate resolve a bug that I knew it’s resolution.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Treat the interview as if you were interacting with a teammate.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After the interview, we talked a bit about Life at Google and I asked all the questions I had. I asked for feedback on my performance, which I learnt would only be delivered to me by my recruiter.&lt;/p&gt;

&lt;p&gt;I waited patiently for feedback.&lt;/p&gt;

&lt;p&gt;A week later… &lt;em&gt;ding dong&lt;/em&gt; … my recruiter contacted me with great news that I passed this stage. Yipppeee!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.pinimg.com%2Foriginals%2Ff0%2F93%2Fac%2Ff093ac120802dc00f8bd3377a14b2b14.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.pinimg.com%2Foriginals%2Ff0%2F93%2Fac%2Ff093ac120802dc00f8bd3377a14b2b14.gif" alt="Smiling teddy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;More preparation for me then!!!!&lt;/p&gt;

&lt;h2&gt;
  
  
  Onsite Stage
&lt;/h2&gt;

&lt;p&gt;Due to my phone interview being so late in the year, the onsite interview had to be pushed to the next year. Admittedly, this should've given me more time to prepare, but because it was the holiday season, I barely utilised the extra time. &lt;/p&gt;

&lt;p&gt;Before the holiday began and after my announcement on &lt;a href="https://www.linkedin.com/posts/chidera-olibie_softwareengineering-google-java-activity-6708649815015755776-p92I" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; , which led to an increased visibility, I was contacted by a recruiter to interview for Bloomberg. I scheduled this immediately and I knew I was prepared because I had spent the last 6 months prepping for Google. The phone interview was really smooth and I got feedback 2 hours later that I had passed, this was quite shocking as I’d read it usually takes up to a week for feedback. &lt;/p&gt;

&lt;p&gt;The onsite interviews were also quite smooth and the interviewers were nice too. Suffice to say that I got accepted into Bloomberg. I held out on accepting the Bloomberg offer as I wanted to complete my Google interview.&lt;/p&gt;

&lt;p&gt;I had also resumed work at Huawei so I had less time to prepare for the Google onsite. However, I made sure to practice at least 2 hours each day, 10pm - 12am.&lt;/p&gt;

&lt;h4&gt;
  
  
  January 2021
&lt;/h4&gt;

&lt;p&gt;I was contacted by my recruiter to schedule my onsite interview. I was really nervous cause I felt a bit rusty from not practicing enough. My motivation came from a friend who reminded me that I had aced the Bloomberg interview and that Google should be no different.&lt;/p&gt;

&lt;p&gt;I had 5 sets of interviews ahead of me.&lt;/p&gt;

&lt;p&gt;Technical Interview 1 - This was a typical medium Leetcode problem. It went really well. I easily understood and was able to find a solution to the problem.&lt;br&gt;
Technical Interview 2 - Same as one&lt;br&gt;
Technical Interview 3 &amp;amp; 4 - These were quite difficult. I almost wasn’t sure I’d done well enough to get. Sure I got the solution but I knew there was still room for optimisation.&lt;br&gt;
Behavioural Interview - This was my best interview so far. It felt like a discussion where the interviewer was trying to know about me and my experiences. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Show your personality to your interviews so that they are also rooting for you to join the company.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The wait for the results felt like I was planking. The days went by so slowly. On the 7th day, I got a call from my recruiter to inform me that I’d gotten in. Hurray…. I was now a Noogler.&lt;/p&gt;

&lt;p&gt;I have since then proceeded to choose a team, go through the Hiring Committee and sign my offer letter. &lt;/p&gt;

&lt;p&gt;I officially started work on the 12th April, 2021.&lt;/p&gt;

&lt;p&gt;Looking forward to all the amazing things I help build at Google.&lt;/p&gt;

&lt;p&gt;Making the Web a better place, one code at a time.&lt;/p&gt;




&lt;p&gt;I’ve met a lot of interesting people during my practice. People who have invariably made my skills better, some of whom have introduced me to their recruiters, given me premium access to coding websites and taught me advanced techniques for problem solving.&lt;/p&gt;

&lt;p&gt;Let’s all just agree that I indeed, enjoyed the process.&lt;/p&gt;

&lt;p&gt;Here are some of the resources I used for practicing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.crackingthecodinginterview.com/" rel="noopener noreferrer"&gt;Cracking the Coding Interview&lt;/a&gt; by Gayle Laakmann McDowell - Indeed a wonderful read. It also has a github link where the problem sets are solved for all languages.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/learn/algorithms-part1" rel="noopener noreferrer"&gt;Introduction to Algorithms I&lt;/a&gt; - Princeton University, Coursera. This taught me the inner details of data structures and problem. Con is that, it is based on Java&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.coursera.org/learn/algorithms-part2" rel="noopener noreferrer"&gt;Introduction to Algorithms II&lt;/a&gt; - Princeton University, Coursera&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.edx.org/course/computer-hardware-and-operating-systems" rel="noopener noreferrer"&gt;Operating Systems and Hardware&lt;/a&gt; - New York University, Edx. This helped with understand system design topics.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://leetcode.com" rel="noopener noreferrer"&gt;Leetcode&lt;/a&gt; - For algorithms practice&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hackerrank.com" rel="noopener noreferrer"&gt;Hackerrank&lt;/a&gt; - Same as leetcode&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://pramp.com" rel="noopener noreferrer"&gt;Pramp&lt;/a&gt; - For interview sessions&lt;/li&gt;
&lt;li&gt;And of course, Google search 😆&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tips that worked for me
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Do not rush the process. I recognized that I wasn't ready for Google and took some time to prepare.&lt;/li&gt;
&lt;li&gt;Understand the basic Computer science concepts. Data Structures and Algorithms. How to approach problems.&lt;/li&gt;
&lt;li&gt;During the interviews:

&lt;ul&gt;
&lt;li&gt;Approach it like you were solving with a teammate.&lt;/li&gt;
&lt;li&gt;Ask lots of clarifying questions. Don't assume anything.&lt;/li&gt;
&lt;li&gt;Listen to your interviewers for their hints and use those hints. Asking for help does not reduce your chances.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Practice a lot!!&lt;/li&gt;
&lt;li&gt;Attempt competitions. as much as you can.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>lifeatgoogle</category>
      <category>softwaredeveloper</category>
      <category>noogler</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Topological Sorting</title>
      <dc:creator>Chidera</dc:creator>
      <pubDate>Tue, 26 May 2020 23:28:22 +0000</pubDate>
      <link>https://dev.to/jeni/topological-sorting-4954</link>
      <guid>https://dev.to/jeni/topological-sorting-4954</guid>
      <description>&lt;p&gt;Ever had a situation where you had a set of things to choose from and you had to decide which one should come first, before the other, that is, the order of priority?&lt;/p&gt;

&lt;p&gt;For example, you have a list of courses to take and you have to decide which course precedes the other for maximum understanding. That can be solved with Topological Sort.&lt;/p&gt;

&lt;p&gt;It involves precedence scheduling, deciding what comes before what. &lt;/p&gt;

&lt;p&gt;It is most commonly used in scheduling and graph processing and only works when the graph is directed and has no cycles - Directed Acyclic Graph (DAG).&lt;/p&gt;

&lt;p&gt;Using the course example and relating it to graph:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The courses are the vertices.&lt;/li&gt;
&lt;li&gt;The edges imply precedence.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So if you have a course A, that points to another course B, it simply means that A must be taken before B; represented as A -&amp;gt; B.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;p&gt;First, let's understand how topological sort works in reality.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Lay out all the course names on your table.&lt;/li&gt;
&lt;li&gt;Starting from the first course 0, check if any course should come before it.&lt;/li&gt;
&lt;li&gt;If there is none, you take out that course 1 and add it to stack that shows course order. &lt;/li&gt;
&lt;li&gt;However, if there's a course 1 that should come before 0, you proceed to check that course 2 for a course 3 that should come before it.&lt;/li&gt;
&lt;li&gt;Continue till you find a course that doesn't have any course before it and subsequently add to your stack in that order.&lt;/li&gt;
&lt;li&gt;Thus, popping from the stack, gives you the topological ordering.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hamrZBqD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/chidera/image/upload/v1590535373/topologoical-order.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hamrZBqD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/chidera/image/upload/v1590535373/topologoical-order.png" alt="Topological sorting" width="416" height="240"&gt;&lt;/a&gt;Topological Sorting&lt;/p&gt;

&lt;p&gt;Notice how this translates to a Depth First Search - recursively checking each node till you reach a base value and then return - in this case: before you return from the function, you add the vertex to your stack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Here’s a simple pseudocode:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Store the input as a Directed Graph&lt;/li&gt;
&lt;li&gt;Starting from vertex i, &lt;/li&gt;
&lt;li&gt;Check for vertices connected to it&lt;/li&gt;
&lt;li&gt;If no vertex, add i to your stack and return&lt;/li&gt;
&lt;li&gt;Else, repeat from 3.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Code Solution
&lt;/h2&gt;

&lt;p&gt;Let’s go through the Digraph data structure first of all.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Digraph&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;To understand the digraph structure, go through the comments and test with different values;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Topological Sort&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h3&gt;
  
  
  Cyclic Graphs
&lt;/h3&gt;

&lt;p&gt;The approach of the topological sorting can be used to detect if a graph has cycles. A graph that has a cycle, will try to visit a vertex when it has not returned from it’s recursive call.&lt;/p&gt;

&lt;p&gt;Using our course prerequisites for example, suppose we have courses A B C D&lt;br&gt;
A → B - A must be taken before B&lt;br&gt;
B → C - B must be taken before C&lt;br&gt;
C → D - C must be taken before D&lt;br&gt;
D → A - D must be taken before A, we see that this effectively creates an impossible scenario. We are still in A’s recursion of courses to take and it is saying that we must have taken A.. What a bummer!! &lt;/p&gt;

&lt;p&gt;To detect this in our algorithm; have an array of vertices in the recursion stack, so that once we return from a vertex, we remove it from the stack. If we get to a vertex that is still in the stack, we note that, our tree has a cycle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cycle Detection&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;I suggest you try this out yourself for better understanding and internalization of the working principle.&lt;/p&gt;

&lt;p&gt;Leave a comment or tweet at me &lt;a href="https://twitter.com/dera_jo"&gt;@dera_jo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;PS: I’m currently looking for a job 🙂 . If you’re in need of a Software Developer, with major experience in Back-end Development and some Front-end, I’m your girl!!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>sorting</category>
      <category>javascript</category>
      <category>datastructure</category>
    </item>
    <item>
      <title>What is Recursion?</title>
      <dc:creator>Chidera</dc:creator>
      <pubDate>Sun, 19 Apr 2020 15:13:07 +0000</pubDate>
      <link>https://dev.to/jeni/what-is-recursion-1h2f</link>
      <guid>https://dev.to/jeni/what-is-recursion-1h2f</guid>
      <description>&lt;h1&gt;
  
  
  What is Recursion?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  What is Recursion?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is Recursion?
&lt;/h3&gt;

&lt;p&gt;Recursion in programming, as you may have heard, refers to a function calling itself. A simple example is shown below: &lt;/p&gt;


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


&lt;p&gt;It can be thought of as continuously repeating same thing and at each point, either stop and return to the previous step because you have satisfied some condition or keep repeating using the result of the previous action. You start off something and you keep doing it unless you satisfy a particular condition, which is known as the base case. &lt;/p&gt;

&lt;p&gt;Let’s say, for example, sweeping. Sweeping involves swiping the broom across the floor continuously until you’ve reached the door or a designated point you’ve chosen to stop. You’ll see that, for every next sweep you want to make, you make it considering the result of the previous sweep. You may keep changing direction or stop sweeping. That is how recursion works.&lt;/p&gt;

&lt;p&gt;For a function to be recursive, it must have two parts: the base case and the recursive call.&lt;/p&gt;

&lt;p&gt;The base case ensures that the function does not keep running infinitely. It tells the function when to stop. In the above code, line two &lt;code&gt;if (i &amp;lt; 0) return;&lt;/code&gt; is our base case. In the sweeping action, the base case would be if we reach the door.&lt;/p&gt;

&lt;p&gt;The recursive call, contains a call to the function itself. - in the above code, &lt;code&gt;hello(--i)&lt;/code&gt;; &lt;/p&gt;

&lt;p&gt;If you’ve been following, you’d realize that this is just like the iterative statements we know. The above code could be re-written as:&lt;/p&gt;


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


&lt;p&gt;While the two are very similar, and can be used in place of the other in most cases, there are some fundamental differences.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic differences between Recursion and Iteration
&lt;/h3&gt;

&lt;p&gt;First; recursion takes up more space in memory during execution. When the function is invoked, the function’s call address is placed at the base of the stack. The address of its recursive calls are placed on top of the &lt;a href="http://docs.oracle.com/cd/E24457_01/html/E21994/afamv.html"&gt;call stack&lt;/a&gt;.  The call stack holds the address of the function to be executed in the order, “Last In, First Out”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I4ggN3lN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://igor.io/img/stack-machine/stack-ops.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I4ggN3lN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://igor.io/img/stack-machine/stack-ops.png" alt="stack-ops.png from phpnews." width="806" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These addresses are popped out once the base case is reached and the function call is returned. Since these recursive calls are stored in the call stack, it take up more memory. It thus takes an extra  &lt;code&gt;O(D) space-complexity&lt;/code&gt; where &lt;code&gt;D&lt;/code&gt; is the number of recursive calls.&lt;/p&gt;

&lt;p&gt;Iteration involves repeatedly executing a set of statements. It stores the addresses of the parameters it needs and refers to them during execution. It does not need to create a new call stack or store new variables for each execution like recursion.&lt;/p&gt;

&lt;p&gt;And hence recursion is slower in execution because of the function call overheads (which include setting up the call stacks, storing variables and address to be return to. Though this can be improved by &lt;a href="https://stackoverflow.com/questions/310974/what-is-tail-call-optimization"&gt;tail-call optimization&lt;/a&gt; which doesn’t create new stack.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why and when should I use recursion or iteration?
&lt;/h3&gt;

&lt;p&gt;So you might be wondering, why should I use recursion when it’s more costly in some cases? My answer to that is, Recursion shouldn’t generally be your first approach if you need to do something repeatedly. If you can do it with iteration simply, then go on ahead. &lt;/p&gt;

&lt;p&gt;However, you can use recursion when your data needs to be broken down into smaller, repetitive instances. And when you need to, ‘divide and conquer’ your problems. Like sorting an array, dealing with graph and tree data structures (like a file directory). Just use it, when it feels natural and you aren’t worried about space or when you can’t seem to find a simple iterative solution to your problem. I’ve not seen any case where recursion was chosen over iteration in web development.&lt;/p&gt;

&lt;h2&gt;
  
  
  More Code Examples
&lt;/h2&gt;

&lt;p&gt;Some examples of recursive functions are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Factorial problem:&lt;/strong&gt; Find the factorial of a given integer. For e.g, 5! = 5 * 4 * 3 * 2 * 1&lt;/li&gt;
&lt;/ol&gt;


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


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tUS9VZRP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_59DDB67A998FFD04EF58F6BB164871A203D8D907699809C3A034796F15BF96C3_1587162052222_image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tUS9VZRP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://paper-attachments.dropbox.com/s_59DDB67A998FFD04EF58F6BB164871A203D8D907699809C3A034796F15BF96C3_1587162052222_image.png" alt="call stack representation of fact(5)  by @dera_jo" width="720" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Our hello example:&lt;/strong&gt; Here, we will compare two versions of the example.&lt;/li&gt;
&lt;/ol&gt;


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


&lt;p&gt;Each recursive call returns to the address of the function that called it and finishes up execution.&lt;/p&gt;


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


&lt;p&gt;So the recursive calls, when it reaches the base case, returns each of the functions to the function that called it and that function then, continues execution using the returned variables and the variables stored at that execution context.&lt;/p&gt;

&lt;p&gt;I hope that helped you understand recursion more! Feel free to leave your comments or follow me on Twitter &lt;a href="https://twitter.com/@dera_jo"&gt;@dera_jo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>recursion</category>
      <category>javascript</category>
      <category>programming</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Implement Serverless Text Sentiment Analysis using Azure Text Analysis API</title>
      <dc:creator>Chidera</dc:creator>
      <pubDate>Tue, 10 Dec 2019 13:52:11 +0000</pubDate>
      <link>https://dev.to/jeni/implement-serverless-text-sentiment-analysis-using-azure-text-analysis-api-kp</link>
      <guid>https://dev.to/jeni/implement-serverless-text-sentiment-analysis-using-azure-text-analysis-api-kp</guid>
      <description>&lt;p&gt;As part of the &lt;a href="https://25daysofserverless.com/calendar/5"&gt;day 5&lt;/a&gt; task for the Microsoft Azure &lt;a href="https://twitter.com/search?q=%2325DaysOfServerless"&gt;#25daysofserverless&lt;/a&gt; challenge on twitter, I implemented language and sentiment analysis using Azure Text Analytics API. &lt;/p&gt;

&lt;p&gt;For the task, you are expected to determine if a child has been nice or naughty based on messages sent to Santa. Of course, these are children from different parts of the world hence different countries. In this article, you will learn "how to implement text sentiment analysis" using "Azure Text Analytics". &lt;/p&gt;

&lt;p&gt;We would be using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nodejs&lt;/li&gt;
&lt;li&gt;Visual Studio Code&lt;/li&gt;
&lt;li&gt;Azure Functions&lt;/li&gt;
&lt;li&gt;Azure Text Analytics&lt;/li&gt;
&lt;li&gt;Postman for testing&lt;/li&gt;
&lt;li&gt;Axios for https requests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First, we need to create a serverless function using Azure. For more details on how to do this using VSCode, visit &lt;a href="https://docs.microsoft.com/en-gb/azure/azure-functions/functions-create-first-function-vs-code?WT.mc_id=25daysofserverless-github-cxa"&gt;this link&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Next, we obtain our configuration keys from the Azure portal. The keys are required to access the Text Analytics API. To get this key, you can:&lt;/p&gt;

&lt;p&gt;Create a cognitive service resource: analytics through the Azure portal.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6uq3zbwj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/3cfb7MDWqnWpQrd48ygFX14S2MDwDoJ8sLthGGg8tskfQF5lFia-IhPlil64E7zhydUPcEckKoqJGsen_zhpCBXrQKKgYvZjhpvmWCCMxzWKgpgdC6KJSxrCf7DC6qagcNCwUx-v" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6uq3zbwj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/3cfb7MDWqnWpQrd48ygFX14S2MDwDoJ8sLthGGg8tskfQF5lFia-IhPlil64E7zhydUPcEckKoqJGsen_zhpCBXrQKKgYvZjhpvmWCCMxzWKgpgdC6KJSxrCf7DC6qagcNCwUx-v" alt="Cognitve service dashboard" width="880" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or follow &lt;a href="https://azure.microsoft.com/en-gb/try/cognitive-services/#lang"&gt;this link&lt;/a&gt; to cognitive services and generate your trial key valid for 7 days.&lt;/p&gt;

&lt;p&gt;Then add these keys to your env file or configuration file. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WKUg0tu4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/7HGIVo8t-JZVToEvju5Ivg3Y84voahgHQlQnq_wN4YmaoVbrvfomziZX2rP0wz6iXlYObsO6edYflVD1bbIMZ0xD7IhVUM3TsEaR_MSLvW1FAcuuVX2wNbbBDdMULLNd8-ZHdbTp" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WKUg0tu4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/7HGIVo8t-JZVToEvju5Ivg3Y84voahgHQlQnq_wN4YmaoVbrvfomziZX2rP0wz6iXlYObsO6edYflVD1bbIMZ0xD7IhVUM3TsEaR_MSLvW1FAcuuVX2wNbbBDdMULLNd8-ZHdbTp" alt="config file" width="631" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we are done with the setup, we will proceed to create the functions that will handle the analysis. They are divided into two:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Determine the language&lt;/li&gt;
&lt;li&gt;Determine the sentiment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To store this functions, I created a different file named congnitives.js so as to abstract these functions from my main code. &lt;/p&gt;

&lt;p&gt;First, I ensure that I have the proper keys to hit my api endpoint. If the key is missing, an error is thrown and we assign the path for fetching languages and sentiments from the API. &lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;I created an asynchronous function get_language that takes in an object with a property 'documents' that holds the text to be analysed in JSON format as a parameter.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Then specified the endpoint to be used for the request. Next, I set the headers with content-type and my subscription key.&lt;/p&gt;

&lt;p&gt;NB: Ensure that the content-type set is of JSON format as that is what the text analytics API accepts.&lt;/p&gt;

&lt;p&gt;Then, using axios, I await my post request to the URL, specifying the text as the body and then set the headers. &lt;/p&gt;

&lt;p&gt;Subsequently, I create another asynchronous function that analyses a given document and provides the sentiment. the sentiment score ranges from 0 to 1 with numbers closer to 1 being positive while the ones closer to zero are negative. Then I export the two functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;


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


&lt;p&gt;I import the two functions I had created in cognitives.js using object destructuring. &lt;/p&gt;

&lt;p&gt;I fetch the list of messages to be analyzed, in my case, using a URL which returned them as an array of objects.&lt;br&gt;
Then I looped through the array to obtain the particular data needed for the language analysis and stored them in the format shown below:&lt;br&gt;
Next, I call the get_language function, which I await because the result is needed for further processing. A successful response is returned in JSON, as shown in the following example: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g4FXBFiG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/nXnawqUi1XcDWqGQWH-sQvybFE7y7t09qHuHWN68kp-5bPGUPfiG0q9W9OqhhqHwUcRf1q3muYYWyfxi2Ml2pSgIJC8UrtdXa3kCodFD" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g4FXBFiG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/nXnawqUi1XcDWqGQWH-sQvybFE7y7t09qHuHWN68kp-5bPGUPfiG0q9W9OqhhqHwUcRf1q3muYYWyfxi2Ml2pSgIJC8UrtdXa3kCodFD" alt="get_language response" width="512" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I proceed to do store the data in the format required for sentiment analysis, call the get_sentiment function and expect a response as shown:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rCWU5-OU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/dSwHf8Ladwcdk9Fgf10tczIygh4_zqweN5ICxzm7syhRPlrDOY5fojwkp8J4qNgPML_6hxRdkGbyHMDh9G44Ht7WO1rEWKn6iwdT03U" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rCWU5-OU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/dSwHf8Ladwcdk9Fgf10tczIygh4_zqweN5ICxzm7syhRPlrDOY5fojwkp8J4qNgPML_6hxRdkGbyHMDh9G44Ht7WO1rEWKn6iwdT03U" alt="get_sentiment response" width="512" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After sentiment analysis, using the results, I can now classify the letters and kids as naughty or nice. Sentiment is positive if closer to 1 and negative if close to 0. Hence if score is greater than or equal to 0.5, it is classified as nice. Otherwise, it will be classified as naughty.&lt;br&gt;
.&lt;br&gt;
This I send back to Santa🎅 and Santa is happy 🤩🤩.&lt;/p&gt;

&lt;p&gt;If you have any questions or comments, feel free. Don't forget to leave thumbs up if you found the article helpful.&lt;/p&gt;

&lt;p&gt;Follow me on Twitter &lt;a href="https://twitter.com/dera_jo"&gt;@dera_jo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cognitiveservices</category>
      <category>javascript</category>
      <category>serverless</category>
      <category>azure</category>
    </item>
  </channel>
</rss>
