<?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: Meet Zaveri</title>
    <description>The latest articles on DEV Community by Meet Zaveri (@meet_zaveri).</description>
    <link>https://dev.to/meet_zaveri</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%2F92680%2F0ca4951f-507a-46c4-83b8-9d4cd65050ba.jpg</url>
      <title>DEV Community: Meet Zaveri</title>
      <link>https://dev.to/meet_zaveri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meet_zaveri"/>
    <language>en</language>
    <item>
      <title>A simpler way to understand time complexity in algorithms</title>
      <dc:creator>Meet Zaveri</dc:creator>
      <pubDate>Thu, 28 Mar 2019 13:16:45 +0000</pubDate>
      <link>https://dev.to/meet_zaveri/a-simpler-way-to-understand-time-complexity-in-algorithms-2j47</link>
      <guid>https://dev.to/meet_zaveri/a-simpler-way-to-understand-time-complexity-in-algorithms-2j47</guid>
      <description>&lt;h2&gt;
  
  
  Understanding it with array and object as a data structure
&lt;/h2&gt;

&lt;p&gt;Let's analyze time complexity for finding a value from a data structure,&lt;/p&gt;

&lt;p&gt;Suppose a data structure would be an array. So to find a value in array, you might have to traverse through array to find a value.&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Worst time complexity : O(n)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;



&lt;p&gt;&lt;code&gt;Best time complexity : O(1)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Here &lt;code&gt;O(n)&lt;/code&gt; means it will iterate through all elements in an array of size &lt;code&gt;n&lt;/code&gt;. &lt;code&gt;O(1)&lt;/code&gt; in a nutshell, means regardless of size of array(i.e. input provided), we can find value on one attempt.&lt;/p&gt;

&lt;p&gt;Instead if a data structure would be an object or hashmap, we could find value directly by knowing it's key assigned to it. So here time complexity would be constant as O(1)&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Time complexity : O(1)&lt;/code&gt;&lt;br&gt;
&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foeme0iej2su7s4yzwv67.jpg" 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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foeme0iej2su7s4yzwv67.jpg" alt="https://thepracticaldev.s3.amazonaws.com/i/oeme0iej2su7s4yzwv67.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Operations in an Array
&lt;/h2&gt;

&lt;p&gt;INSERT (PUSH): Insert operation in array would take &lt;code&gt;O(1)&lt;/code&gt; runtime to push data into array as it knows it has to push at last index of an array.&lt;/p&gt;

&lt;p&gt;DELETE (POP): It's best runtime would be same as insert operation it will take &lt;code&gt;O(1)&lt;/code&gt; if we want to delete from beginning or at the end of the collection. &lt;/p&gt;

&lt;p&gt;But if we want to delete item in middle of the collection, it's runtime would be &lt;code&gt;O(n)&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Analogy for it!
&lt;/h2&gt;

&lt;p&gt;A lot of students get confused while understanding the concept of time-complexity, but in this article, we will explain it with a very simple example:&lt;/p&gt;

&lt;p&gt;Imagine a classroom of 100 students in which you gave your pen to one person. Now, you want that pen. Here are some ways to find the pen and what the O order is.&lt;/p&gt;

&lt;p&gt;O(n2): You go and ask the first person of the class, if he has the pen. Also, you ask this person about other 99 people in the classroom if they have that pen and so on,&lt;br&gt;
This is what we call O(n2).&lt;/p&gt;

&lt;p&gt;O(n): Going and asking each student individually is O(N).&lt;/p&gt;

&lt;p&gt;O(log n): Now I divide the class into two groups, then ask: “Is it on the left side, or the right side of the classroom?” Then I take that group and divide it into two and ask again, and so on. Repeat the process till you are left with one student who has your pen. This is what you mean by O(log n). &lt;/p&gt;

&lt;p&gt;That's it, thanks for reading guys!&lt;/p&gt;

</description>
      <category>algorithms</category>
    </item>
    <item>
      <title>I wondered how async module works, so I made some functions and hosted on npm</title>
      <dc:creator>Meet Zaveri</dc:creator>
      <pubDate>Fri, 24 Aug 2018 08:54:26 +0000</pubDate>
      <link>https://dev.to/meet_zaveri/i-wondered-how-functions-work-in-async-so-i-made-some-and-hosted-on-npm-3m1n</link>
      <guid>https://dev.to/meet_zaveri/i-wondered-how-functions-work-in-async-so-i-made-some-and-hosted-on-npm-3m1n</guid>
      <description>&lt;p&gt;Since I have been in node.js development, I used caolan's async module very often. They provide best collections to boost productivity in development for APIs.&lt;/p&gt;

&lt;p&gt;One day I was like wondering on my desk that how this &lt;code&gt;async.auto()&lt;/code&gt; or &lt;code&gt;async.parallel()&lt;/code&gt; works so flawlessly. Also I was curious and wanted to know how would be picture behind this like function compositions, callback implementation and handling iteration for series control flow.&lt;/p&gt;

&lt;p&gt;I started trying to implement few of them, though didn't accomplished more sophisticated approach like caolan's. I did refactoring and maintained only few of them and limited to mainstream/common control flow methods.&lt;/p&gt;

&lt;p&gt;Tested all of it, though need more use cases to find issues but still it's working when I made it out of a litte sandbox.&lt;/p&gt;

&lt;p&gt;Motivation - Curious about async and wanted to take out more from beautiful callbacks.&lt;br&gt;
Github - &lt;a href="https://github.com/meetzaveri/elite-set-of-async-utilities"&gt;https://github.com/meetzaveri/elite-set-of-async-utilities&lt;/a&gt; &lt;br&gt;
 NPM - &lt;a href="https://www.npmjs.com/package/vanilla-async"&gt;https://www.npmjs.com/package/vanilla-async&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feedback appreciated much more !&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>async</category>
    </item>
  </channel>
</rss>
