<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aqib Ilyas on Medium]]></title>
        <description><![CDATA[Stories by Aqib Ilyas on Medium]]></description>
        <link>https://medium.com/@aqib-ilyas?source=rss-88e88d3a1144------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*mZLvMOFSsCibKpM7SvHNDA.jpeg</url>
            <title>Stories by Aqib Ilyas on Medium</title>
            <link>https://medium.com/@aqib-ilyas?source=rss-88e88d3a1144------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 17:50:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aqib-ilyas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What actually wins a Stripe dispute when you sell software, courses or memberships]]></title>
            <link>https://medium.com/@aqib-ilyas/what-actually-wins-a-stripe-dispute-when-you-sell-software-courses-or-memberships-d7311a0a40f2?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7311a0a40f2</guid>
            <category><![CDATA[enterpreneurship]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[saas]]></category>
            <category><![CDATA[stripe]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Mon, 19 Oct 2026 19:20:05 GMT</pubDate>
            <atom:updated>2026-10-19T19:20:05.528Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_oth7Bo8kwvHu-nLzK2QdA.png" /></figure><h3>The proof is usually in your product, not in Stripe. Here’s what to send, what to skip, and when to accept.</h3><p>A Stripe dispute email always lands at a bad moment. The payment is already gone from your balance, a dispute fee went with it, and a deadline is counting down.</p><p>If you sell physical goods, the playbook is well known: tracking number, delivery confirmation, done. If you sell software, an online course or a membership, it’s less obvious. There’s no parcel, and “the customer had access” doesn’t sound like proof.</p><p>It is, though, if you show it the right way. I’ve spent the last months building a tool that answers Stripe disputes for digital businesses, and reading a lot of Stripe’s documentation on what issuers accept. This is what I’ve learned about what wins, what doesn’t, and when fighting isn’t worth it.</p><h3>First, what a dispute costs you</h3><p>When a customer disputes a payment, Stripe takes the amount plus a dispute fee ($15 in the US) from your balance straight away. That fee isn’t refunded, even if you win.</p><p>If you decide to fight, Stripe charges a counter fee (also $15 in the US) when you submit evidence. You get that one back if you win.</p><p>So for a $500 dispute in the US:</p><ul><li>Accept it, or don’t respond: you lose $515.</li><li>Fight and lose: you lose $530.</li><li>Fight and win: you lose $15, the dispute fee.</li></ul><p>And if you let Stripe’s Smart Disputes respond for you, Stripe keeps 30% of whatever it wins back.</p><p>Two things follow from that. Fighting a weak case makes it more expensive, not less. And a strong case is worth a lot more than the effort it takes to make it.</p><h3>The evidence that wins for digital products</h3><p>The card issuer, not Stripe, decides the outcome. What issuers respond to is simple: facts that show the real cardholder bought something and got it.</p><p>For a digital business, those facts live in your product.</p><p>1. Use after payment. Logins, lessons completed, files downloaded, features used, with dates and times after the purchase. Use after the dispute date is especially strong: it’s hard to claim you never got something you’re still using.</p><p>2. The same IP address or device as checkout. A login from the IP address used at purchase ties the person using the product to the person who paid. For “fraudulent” disputes (“I didn’t make this purchase”), this is often the single most persuasive item.</p><p>3. Earlier undisputed payments. For Visa fraud disputes, Visa’s Compelling Evidence 3.0 rules let you point to at least two earlier, undisputed payments on the same card, made 120 to 364 days before the disputed one. They count if they match on the right identifiers, such as the purchase IP address, the device, the customer’s account ID or their email. When it qualifies, Stripe says it significantly improves your chances. For subscriptions, you often already have those earlier payments.</p><p>4. Their own words. Support emails or chat messages where the customer talks about using the product, asks a question about a lesson, or asks for a feature. One honest message from the customer outweighs pages of your own explanation.</p><p>5. The terms they agreed to, at the moment they agreed. For “subscription canceled” disputes, the relevant part of your cancellation policy, and how the customer accepted it at checkout. That means the relevant section, not your whole terms of service.</p><h3>Match the evidence to the reason</h3><p>Stripe tells you the dispute reason. Send what answers that reason, and leave out the rest.</p><ul><li>Fraudulent or unrecognized: card checks (CVC, address match, 3D Secure if used), the purchase IP address, later logins from the same IP or device, use after payment, and earlier undisputed payments.</li><li>Subscription canceled: your cancellation policy and how they agreed to it, proof there was no cancellation request before the charge, and use after the renewal date.</li><li>Product not received: for digital products, delivery is access. Send the account creation or access email, then logins and downloads.</li><li>Product unacceptable: the product as described at checkout, evidence they used it (which often contradicts “unusable”), your refund policy, and your replies to any complaint.</li></ul><h3>How to present it</h3><p>Issuers read a lot of these, quickly. A few things make a real difference:</p><ul><li>Lead with a short summary. One paragraph: who bought what, when, and the two or three facts that prove it. Then the timeline.</li><li>Prove, don’t argue. “This customer is clearly lying” persuades nobody. “Logged in 14 times after the payment, from the same IP address as checkout” does.</li><li>Keep it short and readable. Stripe recommends 12-point text or larger, and bold rather than colour highlighting. Stay within Stripe’s limits: 4.5 MB in total, and no more than 19 pages for Mastercard.</li><li>No links. Issuers don’t follow them. Put the content in the document.</li><li>Submit once, and early. You can normally submit evidence only once per dispute, and there are no extensions.</li></ul><h3>When not to fight</h3><p>This part rarely gets said. Sometimes the best response is to accept.</p><p>If all you have is the receipt (no logins, no usage, no messages), you’re likely to lose, and fighting adds the counter fee to the loss. The same goes for small amounts: on a $12 dispute, even a likely win barely covers the fee.</p><p>Accepting isn’t an admission of anything. It’s a financial decision. What matters is knowing which cases are which before you spend money on them.</p><h3>Prevent the next one</h3><p>Two habits reduce disputes before they happen:</p><ul><li>Refund early when it’s cheap. If a payment gets an early fraud warning and the amount is about the size of the dispute fee or less, refunding is usually cheaper than a likely dispute.</li><li>Stop the renewal. A dispute on a subscription payment usually means the next renewal will be disputed too. Cancelling, or at least stopping future renewals, prevents a second dispute on the same customer.</li></ul><h3>Why I built Flatfight</h3><p>Doing all of this by hand for every dispute is slow, and most small teams don’t have the logins and support history in one place when the deadline arrives.</p><p>So I built <a href="https://flatfight.com/?utm_source=medium&amp;utm_medium=article&amp;utm_campaign=what-wins">Flatfight</a>. It connects to your Stripe account and your product data (PostHog, Segment, RudderStack, Teachable, Thinkific, Intercom, Help Scout, or a CSV), builds the evidence for each dispute reason, scores each case honestly so you know when to accept, and submits only when you click. It costs a flat $9 per won dispute ($19 from $100), nothing if you lose, and never a percentage of what you win.</p><p>Whether or not you use it, I hope the checklist above saves you a dispute or two. If you’ve fought Stripe disputes before, I’d love to hear in the comments what evidence ended up mattering for you.</p><p><em>Further reading: </em><a href="https://flatfight.com/stripe-dispute-evidence-guide"><em>the full Stripe dispute evidence guide</em></a><em> and </em><a href="https://flatfight.com/stripe-chargebacks"><em>what Stripe chargebacks cost</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7311a0a40f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multitasking vs Multithreading vs Multiprocessing]]></title>
            <link>https://medium.com/codex/multitasking-vs-multithreading-vs-multiprocessing-2b0087c861ae?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b0087c861ae</guid>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[multiprocessing]]></category>
            <category><![CDATA[parallel-computing]]></category>
            <category><![CDATA[multitasking]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Thu, 04 Aug 2022 08:45:34 GMT</pubDate>
            <atom:updated>2022-08-04T15:43:21.618Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*syyujsSST2CeIIbIdFWVCg.png" /></figure><p>Computers today are very smart and can perform multiple operations at once. This ability of computers to run multiple tasks at the same time is called <strong>Multitasking</strong>.</p><p>A single core computer can never run multiple programs at the same time. What it does is that it gives a little bit of time to every program being executed creating an illusion of multitasking. For example, if we run two different programs or multiple instances of the same program on a single core, it will run 1 instance/program for a few seconds/milliseconds and then switch to the other program being executed and give it resources for some time and so on. This is called multitasking, where the computer uses its context switching ability to switch back and forth between multiple programs. This will definitely increase program execution time as multiple programs are sharing the same CPU resources and time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ZLLxUUq4C5T3n3VwNd2AEg.png" /><figcaption>geeksforgeeks.com</figcaption></figure><p><strong><em>What if a program being executed has multiple threads?</em></strong></p><p>A <strong>thread</strong> is the smallest piece of instructions from a large program. If a single program/process needs to do multiple tasks concurrently, it divides these tasks into threads. For instance, an application has to download the data and update the progress bar as well, it can download data in one thread and update UI in the other. Some important properties of threads are:</p><ul><li>sub-tasks of the main program</li><li>Share CPU resources with each other</li><li>can be paused, stopped, and resumed</li></ul><p>This way of executing multiple threads/tasks of a single process/program is called <strong>Multithreading.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*o6gwyGaV6KuwLMnsY6W9_Q.png" /></figure><blockquote>Multithreading is a kind of multitasking where multiple tasks being executed are part of same program.</blockquote><p>Now let’s assume we have a dual-core computer and we try to run a single non-threaded program, the CPU will execute that program in a single core and provide all its resources while the other core will sit free. When we try to run multiple non-threaded programs on a multi-core CPU, the computer will again utilize its multitasking ability and give each program, resources from its cores. A single program will run completely on 1 core while the other on the second and so on. CPU will give some time to each individual program being executed on its all cores. This is called <strong>Multiprocessing.</strong></p><blockquote>Multiple non-threaded programs share CPU cores but they will always complete their execution on a core where an execution was first started.</blockquote><p>When we try to run the multi-threaded program on a multi-core CPU, the CPU will utilize its cores and run threads on all available cores. This is multi-threading on a multi-core CPU and this is also called<strong> Multiprocessing.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*UuYxB7xJXKU_g5F3l90fcw.png" /></figure><p>To conclude, multithreading and multiprocessing utilize the computer’s multitasking ability which in turn use <strong>context switching</strong>.</p><ul><li>In multitasking, multiple programs and threads share the same CPU core.</li><li>In multithreading, different threads of the same program share the same CPU core and execute concurrently.</li><li>In multiprocessing, multiple programs and even multiple threads of the same program utilize all CPU cores available and this is the truest form of <strong>parallel processing </strong>where the CPU executes multiple programs or threads in parallel on its different cores.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b0087c861ae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/multitasking-vs-multithreading-vs-multiprocessing-2b0087c861ae">Multitasking vs Multithreading vs Multiprocessing</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OOP in JavaScript: Encapsulation, Inheritance, Polymorphism, Abstraction, and Association]]></title>
            <link>https://medium.com/codex/oop-in-javascript-encapsulation-inheritance-polymorphism-abstraction-and-association-2cbcd93bbb4f?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cbcd93bbb4f</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[oop-concepts]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Fri, 22 Jul 2022 13:36:59 GMT</pubDate>
            <atom:updated>2022-07-22T14:34:51.692Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*XFVtjH6kCb1K0sSfSjjCng.png" /></figure><p>Object Oriented Programming is a commonly used software design pattern and is a very popular paradigm of programming. It’s used to structure code in such a way that code is reusable, easily readable, and scalable. It involves the use of classes and objects and almost all programming languages support this pattern.</p><p>In JavaScript, functions are objects. So we can achieve OOP pattern without the use of classes.</p><p>Let’s learn the basics of OOP and implement it using JavaScript.</p><p><strong>Classes and Objects:</strong></p><p>A class is a blueprint with which objects/variables are created. It is a custom data type containing properties and methods. An object is an instance of a class that uses the class’s methods and properties. Let’s understand and implement this via javascript:</p><pre>class Animal{<br>    constructor(name){<br>        this.name = name;<br>    }<br>}</pre><pre>// Let&#39;s create Object from the class Animal<br>var animal = new Animal(&quot;Dog&quot;);</pre><p><em>A </em><strong><em>constructor </em></strong>is a special keyword reserved to create a constructor function. A constructor function is always called automatically upon the creation of an object/instance of a class. It implicitly returns an instance of the newly created object. A default constructor is built-in to the class and we override it by implementing our own. The <strong><em>new </em></strong>keyword is necessary to use with object creation as it will tell the compiler to invoke the constructor function.</p><p>In Javascript, we can create Objects using functions without the use of the class keyword.</p><pre>function Animal(name){<br>    this.name = name;<br>}</pre><pre>var animal = new Animal(&quot;Dog&quot;);</pre><p>This is how we create Objects from functions and classes in javascript. Now that we know classes and objects, let’s learn some more OOP concepts.</p><p><strong>Encapsulation:</strong></p><p>Encapsulation is the process of hiding and securing the properties of objects. Direct access to encapsulated properties is not possible and we have to provide other mechanisms to operate/read that data. Typically, this is done by making class variable properties private and providing public class methods to access necessary data.</p><pre>function Animal(val){<br>    var name = val;<br>    var publicApi = {<br>        setName: function (val){<br>            name = val;<br>        },<br>        getName: function (){<br>            return name;<br>        }<br>    }<br>    <br>    return publicApi;<br>}</pre><pre>var animal = new Animal(&quot;DOG&quot;);<br>animal.setName(&quot;CAT&quot;);<br>console.log(animal.getName());   output: CAT<br>console.log(animal.name);        output: undefined</pre><p>In the above code, the <strong><em>name </em></strong>property of Animal isn’t directly accessible but only via <strong><em>publicApi</em></strong> methods. This is because we are returning publicApi object that doesn’t have a name property. Its properties(setName and getName) utilize name property from its lexical scope.</p><p>Via class, this can be done by making class variables private using # before the name of the variable.</p><pre>class Animal{<br>    #name;<br>    constructor(name){<br>        this.#name = name;<br>    }<br>    <br>    setName(val){<br>        this.#name = val;<br>    }<br>    <br>    getName(){<br>        return this.#name;<br>    }<br>}<br>var animal = new Animal(&quot;DOG&quot;);<br>animal.setName(&quot;CAT&quot;);<br>console.log(animal.getName());    output: CAT<br>console.log(animal.name);         output: undefined</pre><blockquote>Encapsulation can also be done by making modules out of code</blockquote><p><strong>Abstraction:</strong></p><p>Abstraction means hiding the implementation details and showing only behavior. It’s done on the design level as opposed to encapsulation which is implemented at the application level. With abstraction, only essential details are shown to the user.</p><p>Consider this code snippet:</p><pre>class Employee{<br>    #name;<br>    #baseSalary;<br>    <br>    <br>    setName(val){<br>        this.#name = val;<br>    }<br>    setBaseSalary(val){<br>        this.#baseSalary = val;<br>    }<br>    <br>    getName(){<br>        return this.#name;<br>    }<br>    <br>    getSalary(){<br>        let bonus = 1000;<br>        return this.#baseSalary + bonus;<br>    }<br>}<br>var emp = new Employee();<br>emp.setName(&quot;abc&quot;);<br>emp.setBaseSalary(100);<br>console.log(emp.getName());<br>console.log(emp.getSalary());</pre><p>Notice how <strong><em>getSalary</em></strong> method is updating salary in the backend that the end user wouldn’t know. In a real application, this bonus can be fetched from some database and added to the base salary.</p><p>Via function, this can be done using the following code:</p><pre>function Employee(){<br>    let name;<br>    let baseSalary;<br>    <br>    var publicApi = {};<br>    <br>    publicApi.setName = function (val){<br>        name = val;<br>    }<br>    publicApi.setBaseSalary = function (val){<br>        baseSalary = val;<br>    }<br>    <br>    publicApi.getName = function (){<br>        return name;<br>    }<br>    <br>    publicApi.getSalary = function (){<br>        let bonus = 1000;<br>        return baseSalary + bonus;<br>    }<br>    return publicApi;<br>}<br>var emp = new Employee();<br>emp.setName(&quot;abc&quot;);<br>emp.setBaseSalary(100);<br>console.log(emp.getName());<br>console.log(emp.getSalary());<br>console.log(emp.name);</pre><p><strong>Inheritance:</strong></p><p>Inheritance is an important concept in Object Oriented Programming paradigm. It’s a process by which child objects inherit the properties of the parent object. In javascript, inheritance is built into objects and every object has a property called prototype which refers to the parent of that object and this chain goes up until the prototype points to null.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ynd6bGI7YwpHgIjeA4WBcQ.png" /></figure><p>As you can see above, the Obj has a default prototype property referring to Object which is a built-in data type.</p><p>Now let’s implement inheritance via classes and objects:</p><pre>class Person{<br>    constructor(name){<br>        this.name = name;<br>    }<br>    sayName(){<br>        console.log(this.name);<br>    }<br>}</pre><pre>class Student extends Person{<br>    constructor(name, rollNumber){<br>        super(name);<br>        this.rollNumber = rollNumber;<br>    }<br>    logDetails(){<br>        console.log(`Name: ${this.name}, Roll number: ${this.rollNumber}`)<br>    }<br>}<br>var student = new Student(&quot;Heisenberg&quot;, 1);<br>student.logDetails();    // Name: Heisenberg, Roll number:1<br>student.sayName();       // Heisenberg</pre><p>Student class has access to all properties of the person class.</p><p><strong>Polymorphism:</strong></p><p>Polymorphism is the practice to design objects in such a way that they share and override behavior from parent objects.</p><p>When a property is referred to by an object whether it’s a method or variable, the object first looks for it in its own scope, if not found then go one level above and look for it in the parent scope. It goes on until that property is found or returned undefined otherwise. This behavior of javascript objects can be utilized in such a way that child objects can override the functionality of their parent objects where required without modifying the parent.</p><p>In the above code from the inheritance, the student object calls <strong><em>sayName </em></strong>function which is not present in the Student class but in its parent, yet it is callable. We can override this function in the Student class and customize it’s behavior.</p><pre>class Person{<br>    constructor(name){<br>        this.name = name;<br>    }<br>    sayName(){<br>        console.log(this.name);<br>    }<br>}</pre><pre>class Student extends Person{<br>    constructor(name, rollNumber){<br>        super(name);<br>        this.rollNumber = rollNumber;<br>    }<br>    logDetails(){<br>        console.log(`Name: ${this.name}, Roll number: ${this.rollNumber}`)<br>    }<br>    sayName(){<br>        // do stuff<br>        console.log(&quot;From Student&quot;);<br>        super.sayName();<br>    }<br>}<br>var student = new Student(&quot;Heisenberg&quot;, 1);<br>student.logDetails();<br>student.sayName();      // From Student   Heisenberg</pre><p>The <strong><em>super </em></strong>keyword is used to refer to the parent object and call its method. Here we can do operations specific to students in the <strong>Student.sayName</strong> method and then common operations of Student and other children of Person class can be abstracted to <strong>Person.sayName</strong> method.</p><p><strong>Association:</strong></p><p>Association is the design principle by which different Objects can be associated with each other to perform some task. It’s of two types:</p><p><strong>1- Aggregation:</strong></p><p>In Aggregation, objects are loosely coupled and can independently exist. This means an object can exist even after its associated object is destroyed.</p><p>Let’s implement this via javascript:</p><pre>class Wall{<br>    constructor(width, height){<br>        this.width= width;<br>        this.height = height;<br>    }<br>}<br>class Room{<br>    constructor(wall){<br>        this.wall = wall;<br>    }<br>    print(){<br>        console.log(this.wall);<br>    }<br>}</pre><pre>var wall = new Wall(1,1);<br>var room = new Room(wall);<br>wall = null;<br>room.print();</pre><p>Here the wall and room object exist independently.</p><blockquote>Aggregation is also called weak association.</blockquote><p><strong>2- Composition:</strong></p><p>In Composition, objects are tightly coupled and cannot exist independently.</p><p>Here’s the javascript implementation of composition:</p><pre>class Wall{<br>    constructor(width, height){<br>        this.width= width;<br>        this.height = height;<br>    }<br>}<br>class Room{<br>    constructor(width, height){<br>        this.wall = new Wall(width,height);<br>    }<br>    print(){<br>        console.log(this.wall);<br>    }<br>}</pre><pre>var room = new Room(1,1);<br>room.print();</pre><p>If we destroy the room object, the wall is also destroyed as it’s enclosed inside the room object.</p><blockquote><strong>Composition </strong>is also called strong association.</blockquote><p>OOP has a lot of applications and all modern software are built with design pattern based on OOP architecture. Therefore, one must have a solid understanding of above mentioned OOP concepts to build software applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cbcd93bbb4f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/oop-in-javascript-encapsulation-inheritance-polymorphism-abstraction-and-association-2cbcd93bbb4f">OOP in JavaScript: Encapsulation, Inheritance, Polymorphism, Abstraction, and Association</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Binary Search Tree: Implementation in JavaScript]]></title>
            <link>https://medium.com/@aqib-ilyas/binary-search-tree-implementation-in-javascript-c8ca74452167?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/c8ca74452167</guid>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[binary-tree]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Fri, 24 Jun 2022 11:59:53 GMT</pubDate>
            <atom:updated>2022-06-24T11:59:53.547Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*EF8ke-dtqia7TkvrjEGvhQ.png" /><figcaption><a href="https://www.crondose.com/">https://www.crondose.com/</a></figcaption></figure><p>A Binary Search Tree is a specific kind of binary tree where the data of every right child node is greater than its parent node and the data of every left child node is less than its parent node.</p><p>Binary Search Tree is used to perform search operations on data because it can find data in O(log(n)) time which is pretty efficient. Following operations are performed in the BST:</p><ul><li>Insertion</li><li>Deletion</li><li>Searching</li><li>Traversals</li></ul><p><strong>Insertion </strong>in BST is done using the following rules and steps:</p><ul><li>Data is inserted at the root node if the root node is null.</li><li>BST is traversed from the root node such that the next node to be visited is left if the data to be inserted is less than the current node’s data, otherwise, it’s right.</li><li>Finally, the new node is inserted to the left of the current node if its data is less than the current node’s data, otherwise, it’s inserted to right.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cad2a860a7e6d1b7c3eb588e3eb7e42f/href">https://medium.com/media/cad2a860a7e6d1b7c3eb588e3eb7e42f/href</a></iframe><p><strong>Deletion </strong>in BST is done using the following rules:</p><ul><li>If the node to be deleted is a leaf node, it’s made null</li><li>If the node to be deleted has only one child, it’s replaced with that child</li><li>Otherwise, the node is replaced with the smallest data node from its right subtree</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb2972728c8ef7e85431ebb18af458fe/href">https://medium.com/media/eb2972728c8ef7e85431ebb18af458fe/href</a></iframe><p><strong>Searching </strong>is performed by traversing BST such that:</p><ul><li>If the current node value is equal to the value being searched, return true.</li><li>If the value being searched is less than the current node’s value, the next node to be visited is on the left of the current node, otherwise right.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/53e0e799243da50737a5d927c0857a7b/href">https://medium.com/media/53e0e799243da50737a5d927c0857a7b/href</a></iframe><p><strong>Traversals </strong>of BSTs are of three kinds:</p><ul><li>In-order: First left node is traversed, then root, and then right.</li><li>Post-order: First left node is traversed, then right, and then root.</li><li>Pre-order: First root node is traversed, then left, and then right.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6230a0465bb9a1a395a39bf29baba6de/href">https://medium.com/media/6230a0465bb9a1a395a39bf29baba6de/href</a></iframe><p>Here’s the complete JavaScript code implementation of Binary Search Tree.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e3b7a06eb73e248f9da312d345527d8/href">https://medium.com/media/0e3b7a06eb73e248f9da312d345527d8/href</a></iframe><blockquote>In-order traversal on BST will always return an array containing node data in sorted order</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c8ca74452167" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dynamic Programming: An Overview and Implementation]]></title>
            <link>https://medium.com/codex/dynamic-programming-an-overview-and-implementation-e29aa424bad7?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/e29aa424bad7</guid>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Mon, 13 Jun 2022 11:20:12 GMT</pubDate>
            <atom:updated>2022-06-23T13:17:16.541Z</atom:updated>
            <content:encoded><![CDATA[<p>Dynamic programming is an algorithmic approach to solve complex problems in optimal way. Basically, a complex problem is divided into multiple simpler sub-problems that are easier to solve and final solution depends on the solutions of all sub-problems.</p><p>Dynamic programming problems involve recursive patterns where solution is build up from the very base case to all the way up to the top. Therefore, it’s pretty intensive in term of time and space complexity. But there are few techniques which people use to optimize their solution so their algorithms take less time and memory to execute. Most popular ones are:</p><ul><li>Memoization</li><li>Tabulation</li></ul><p><strong>Memoization:</strong></p><p>Lot of sub-problems are repetitive but solved again because of the nature of the recursive algorithms. For example, consider the following Fibonacci sequence:</p><p><em>0, 1, 1, 2, 3, 5, 8, 13, …</em></p><p>We know that every Fib(n) in sequence is equal to Fib(n-1)+Fib(n-2). Let’s look at the code and its tree structure:</p><pre>const Fib = (n) =&gt; {<br>    if(n &lt;= 1) return n;<br>    <br>    return Fib(n-1) + Fib(n-2);<br>}</pre><pre>console.log(Fib(7));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*nRv74IX_MXfUltJbXWeL4Q.png" /><figcaption>coderbyte.com</figcaption></figure><p>From this tree diagram, we can see that to calculate Fib(7), we have to calculate Fib(6) and Fib(5). And to calculate Fib(6), Fib(5) needs to be calculated again along with Fib(4) and this cycle goes on.</p><p>Estimated Time Complexity: O(2^n)</p><p>Estimated Space Complexity: O(n)</p><blockquote>Memoization is a technique in which we store the solutions of sub-problems so that we can use them later where required, hence the repetition is avoided.</blockquote><p>Let’s look at memoized solution:</p><pre>const Fib = (n, memo={}) =&gt; {<br>    if(n in memo) return memo[n];<br>    if(n &lt;= 1) return n;<br>    <br>    memo[n] = Fib(n-1, memo) + Fib(n-2, memo);<br>    return memo[n];<br>}</pre><pre>console.log(Fib(7));</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*BzC72SgmHxQhOOHRoDYJrw.png" /></figure><p>The Fib(2), Fib(3), Fib(4), Fib(5) are calculated once and stored in memo object for later use. Hence this approach calculates result much faster.</p><p>Estimated Time Complexity: O(n)</p><p>Estimated Space Complexity: O(n)</p><p><strong>Tabulation:</strong></p><p>Using this technique, a dynamic problem is solved iteratively instead of recursion. Basically, after determining the relation between main problem and its sub-problems, we start from the very base case and solve up till the main problem. The results are stored in a data structure suitable to kind of problem.</p><p>Let’s solve same Fib(n) problem using this method:</p><pre>const Fib = (n) =&gt; {<br>    const sequence = new Array(n+1).fill(0);<br>    <br>    //base case<br>    sequence[0] = 0;<br>    sequence[1] = 1;<br>    // relation: sequence[i] = sequence[i-1] + sequence[i-2];<br>    <br>    for(let i = 2; i &lt;= n; i++){<br>        sequence[i] = sequence[i-1] + sequence[i-2];<br>    }<br>    return sequence[n];<br>}</pre><pre>console.log(Fib(n));</pre><p>This is another way of optimizing a dynamic problem solution.</p><p>Estimated Time Complexity: O(n)</p><p>Estimated Space Complexity: O(n)</p><blockquote>Both <strong>Memoization </strong>and <strong>Tabulation </strong>are effective to reduce execution time and memory of a dynamic programming algorithm. In, <strong>Memoization</strong>, we tackle this by storing results for later use and in <strong>Tabulation</strong>, iterative approach is taken instead of recursion.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e29aa424bad7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/dynamic-programming-an-overview-and-implementation-e29aa424bad7">Dynamic Programming: An Overview and Implementation</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Trie Data structure: An Overview]]></title>
            <link>https://medium.com/@aqib-ilyas/trie-data-structure-an-overview-61ceeec91d1a?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/61ceeec91d1a</guid>
            <category><![CDATA[trie]]></category>
            <category><![CDATA[graph]]></category>
            <category><![CDATA[datastrucutre]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 12:35:36 GMT</pubDate>
            <atom:updated>2022-06-09T12:37:34.973Z</atom:updated>
            <content:encoded><![CDATA[<p>Trie is a Tree like data structure mostly used to store data that needs to be accessed frequently. This is because it minimizes the search complexities and data can be retrieved in O(M) time where M is the length of the data. It can be visualized using graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*fj795RBBS-uA3R0Oe4oo9w.png" /></figure><p><strong>Steps to build Trie data structure:</strong></p><ul><li>Create an empty root node</li><li>Insert new data as children to the root node</li><li>Before inserting data, traverse from the root node to check if the data already exists in the Trie. Insert data only if it doesn’t exist already.</li><li>Data is always inserted and retrieved by traversing from top(root) to bottom(child) nodes.</li><li>Data is always stored in order from top to bottom without any gap</li></ul><p>Let’s illustrate further via an example.</p><p>Consider a list of words=[“apple”, “able”, “apps”, “bat”]. The Trie structure of this list will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*my2zTuVKGDh5fpmnHGyBwg.png" /></figure><blockquote>Notice how every new character is always inserted from the root. Like in case of inserting “apps”, we traversed from the root and found “app” is already stored in the Trie. So we only added “s” as a suffix to the “app”</blockquote><p><strong>How to Code Trie data structure?</strong></p><p>Let’s try coding the Trie data structure in JavaScript. We know that every single Node in the Trie represents(stores) some data. We can create separate class for that node and then create its multiple instances as required to make Trie.</p><pre>class Node {<br>    constructor() {<br>        this.children = {};<br>        this.isWordEnd = false; <br>  }<br>}</pre><pre>class Trie {<br>    constructor() {<br>        this.root = new Node(&quot;root&quot;); // root node of Trie<br>    }<br>    <br>    // insert data to Trie<br>    insertData(data) {<br>        let current = this.root;<br>        for(const d of data){<br>            if (!current.children.hasOwnProperty(d)) {<br>                current.children[d] = new Node();<br>            }<br>            current = current.children[d];<br>        }<br>        current.isWordEnd = true;<br>    }<br>    <br>    // search data in the Trie<br>    searchData(data) {<br>        let current = this.root;<br>        for(const d of data){<br>            if (!current.children.hasOwnProperty(d)) {<br>                return false;<br>            }<br>            current = current.children[d];<br>        }<br>        return true;<br>    }<br>}</pre><blockquote><strong>isWordEnd()</strong> is optional and can be used if we want to search for complete word in the Trie.</blockquote><p><strong>Use Cases:</strong></p><p>Trie data structure has multiple use cases. It is used in multiple algorithms which involve searching in strings and substrings. Following are the real world applications of Trie:</p><ul><li>Auto-correction of mobile keyboard</li><li>Word suggestion in typing</li></ul><blockquote><strong>Trie </strong>data structure provides <strong>search, insert </strong>and <strong>delete</strong> functions in <strong>O(M)</strong> time where M is the length of data and there is no hashing required.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61ceeec91d1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big O in Programming]]></title>
            <link>https://medium.com/codex/big-o-in-programming-c86803b01532?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/c86803b01532</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[big-o-notation]]></category>
            <category><![CDATA[time-complexity]]></category>
            <category><![CDATA[space-complexity]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Tue, 24 May 2022 11:50:09 GMT</pubDate>
            <atom:updated>2022-06-23T13:17:20.846Z</atom:updated>
            <content:encoded><![CDATA[<p>Program execution takes time and memory and it depends on processing speed of the computer on which program is being executed. It may take 1sec to execute a piece of code on my machine while same code can take more or less time on another machine depending on its processing power. So it means that we can’t measure code performance on basis of execution time and it should be independent of machine resources.</p><p>A good code has two qualities:</p><ul><li><em>Readability</em></li><li><em>Scalability</em></li></ul><p><strong>Readability </strong>means that code is readable and easy to understand for developers. It generally means that code should have proper coding styles, formats, naming conventions and commenting such that other developers find it easy to work with your code.</p><p><strong>Scalability </strong>means that code should be easily scalable for larger inputs and shouldn’t break. For instance, if an app currently has thousand users and in future, the userbase grows to millions, the app should work the same. To develop scalable apps, Big O analysis of code is performed and code is made as efficient as possible.</p><p><strong>Big O notation</strong> is used to evaluate performance matrix of code in term of <strong>Space and Time Complexity</strong>. It tells how well the code will perform for larger inputs by estimating execution time and space irrespective of the hardware it is being executed on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*vgqmgxAUeiKbUFYmnrUpsw.jpeg" /></figure><blockquote><strong>Time Complexity: </strong><em>Estimated amount of Time required for execution</em></blockquote><p>Following points will help you how to calculate Big O Time Complexity of a code:</p><ul><li>Big O of =, +, -, *, /, % is 0(1)</li><li>Big O of loop is O(N) where N is the number of times the loop executed</li><li>Big O is always estimated for worst case scenario</li><li>Generally, O(1) + O(1) + … = O(1) and O(N) + O(N) +…= O(N)</li><li>Also, we neglect constant terms and assignments and only calculate Big O of loops and expensive operations.</li><li>Big O of nested loop is O(N) * O(N) = O(N²)</li><li>For different inputs of nested loops, O(N) * O(M) = O(N*M) = O(P)</li></ul><p>Consider this code:</p><pre>def TwoSum(numbers, target):</pre><pre>    mapValues = {}                                     O(1)</pre><pre>    for i in range(len(numbers)):                      O(N):N=length</pre><pre>        currentVal = mapValues.get(numbers[i], None)   O(1)</pre><pre>        if(currentVal is not None):                    O(1)</pre><pre>            return [currentVal, i]                     O(1)</pre><pre>        else:</pre><pre>            numberToFind = target - numbers[i]         O(1)</pre><pre>            mapValues[numberToFind] = i                0(1)</pre><pre>    return None                                        O(1)</pre><pre><br>Note: Statements inside loop will execute N=length of numbers times, so their complexity will be multiplied with O(N)</pre><pre>Big O = O(1) + O(N)*(O(1) + O(1) + O(1) + O(1) + O(1)) + O(1)</pre><pre>As O(1) + O(1) +O(1) + ... = O(1), so<br>      = O(1) + O(N)*(O(1) + O(1)</pre><pre>Also O(1) + O(N) = O(N) and O(1)*O(N) = O(N)<br>      = O(1) + O(N) + O(1)<br>      = O(N) </pre><blockquote>O(N) is a general term where N stands for large number. We can estimate N/2, N/3 to be equal to N when N is too large.</blockquote><p>Now we can see that ultimately, the complexity depends on how many times the loop is executed and it is generally not calculated for small operations like calculations and assignments.</p><blockquote><strong>Space Complexity: </strong><em>Estimated amount of memory</em> required by program</blockquote><p>Space Complexity is calculated in term of variable initialization inside the program. Space complexity depends on:</p><ul><li>Variables</li><li>Data structures</li><li>Functions calls</li><li>Allocations</li></ul><p>Consider the example below for better understanding:</p><pre>newArray = []                O(1)<br>for i in range(n):<br>    newArray.append(i);      O(N)</pre><pre>Big O = O(1) + O(N) = O(N)</pre><p>Here the space complexity is O(N) because new memory is allocated for array N times.</p><blockquote>For Big O calculation, it is generally estimated that the number of inputs are very large and hence small operations can be neglected, only repetitive operations are considered.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c86803b01532" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/big-o-in-programming-c86803b01532">Big O in Programming</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arrays vs Hash Tables]]></title>
            <link>https://medium.com/@aqib-ilyas/arrays-vs-hash-tables-dd188c9a52d7?source=rss-88e88d3a1144------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd188c9a52d7</guid>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[hash-table]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <dc:creator><![CDATA[Aqib Ilyas]]></dc:creator>
            <pubDate>Tue, 24 May 2022 09:27:41 GMT</pubDate>
            <atom:updated>2022-05-24T09:27:41.575Z</atom:updated>
            <content:encoded><![CDATA[<p>There are multiple Data structures available in different programming languages to store and operate on data. The two most commonly used are Arrays and Hash Tables. This blog will compare the two and will help you decide when to prefer one over the other.</p><h3><strong>Arrays:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*UqlXjkuGNCwVmZ3e6og66A.png" /></figure><p>Arrays are the easy to learn and widely used data structures. These can be static and dynamic depending on your requirement. The data stored in arrays can be accessed via indices 0,1.. and every new item in array is stored next to previous, making it an ordered data structure.</p><p>Most common methods available with arrays are:</p><p><em>1- lookup O(1)</em></p><p><em>2- insert O(N)</em></p><p><em>3- push O(1)</em></p><p><em>4- search O(N)</em></p><p><em>5- delete O(N)</em></p><p>As you can see, most methods are expensive in term of time and processing which makes code inefficient. Therefore, arrays shouldn’t be used to store large amount of data as operations will take longer time to complete.</p><h3><strong>Hash Tables:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b6Fmxd0p7b3pEzV1G1rZPg.png" /></figure><p><strong>Hash Tables</strong> are built-in to most languages like JavaScript, Java and Python etc. and these are stored in memory as key-value pair. Basically, a key is passed to Hash function which hashes it and converts it to memory address where both Key and Value is stored.</p><p>Hash Tables are very fast as most methods available with Hash Tables have complexity of O(1) making them more efficient than Arrays for large amount of data.</p><p><em>1- lookup O(1)</em></p><p><em>2- insert O(1)</em></p><p><em>3- search O(1)</em></p><p><em>4- delete O(1)</em></p><p>This make Hash Table very efficient to work with as compared to arrays but every data structures has its own pros and cons.</p><blockquote>In Hash Table, a <strong>hash function</strong> converts the key to memory address. There may occur a case where different keys can point to same memory address. This is called <strong>Hash Collisions</strong>.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*Ircsf7UHm2aO2MiCQFys5w.png" /></figure><p>This leads to data loss and hence make Hash Tables not too good to store important data. There are certain techniques with which this can be avoided like <strong>Open Addressing</strong> and <strong>Separate Chaining</strong>.</p><blockquote>Alternative to Arrays and Hash Tables are <strong>Linked Lists</strong> where every item contains pointer to next item in the list.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd188c9a52d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>