<?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 Author on Medium]]></title>
        <description><![CDATA[Stories by Author on Medium]]></description>
        <link>https://medium.com/@author-1?source=rss-8d1a76d48b32------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Author on Medium</title>
            <link>https://medium.com/@author-1?source=rss-8d1a76d48b32------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 14:18:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@author-1/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[Solve Any Divide & Conquer Problem With This Trick]]></title>
            <link>https://codeburst.io/solve-any-divide-conquer-problem-with-this-trick-a187810cbd99?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/a187810cbd99</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[efficiency]]></category>
            <category><![CDATA[merge-sort]]></category>
            <category><![CDATA[binary-search]]></category>
            <category><![CDATA[big-o-notation]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Thu, 11 Feb 2021 05:29:25 GMT</pubDate>
            <atom:updated>2021-02-12T02:40:17.593Z</atom:updated>
            <content:encoded><![CDATA[<h4>And ace your next exam or interview</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fPJCoMjCLZqR94_W" /><figcaption>Photo by <a href="https://unsplash.com/@anthonyintraversato?utm_source=medium&amp;utm_medium=referral">Anthony Intraversato</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The Divide and Conquer software design paradigm is notorious for its strong problem solving abilities. By carefully breaking down problems into manageable subproblems, algorithms can efficiently and predictably find solutions.</p><p>However, designing a Divide and Conquer algorithm on the spot is nothing short of difficult. In my personal experience, I’ve been asked to accomplish this task on university exams as well as software engineering interviews. From my successes and failures comes one critical observation — almost every time, the answer is a slight variation of <a href="https://www.geeksforgeeks.org/binary-search/">Binary Search</a> or <a href="https://www.geeksforgeeks.org/merge-sort/">Merge Sort</a>.</p><h3>Now, For Some Review</h3><h4>Binary Search</h4><p>Given a sorted array <strong>A</strong> and a target value <strong>t</strong>, locate the middle element, <strong>m</strong>. If <strong>m</strong> equals <strong>t</strong>, return the index of <strong>m</strong>. If <strong>m</strong> is greater than <strong>t</strong>, recurse on <strong>A</strong>’s right half subarray. Otherwise, recurse on <strong>A</strong>’s left half subarray.</p><p>The recurrence relation is expressed as <strong>T(n) = T(n/2) + O(1)</strong>, allowing for a time complexity of <strong>O(log(n))</strong>.</p><p>This is significantly faster than searching an array with brute force (O(n)).</p><h4>Merge Sort</h4><p>Given an array <strong>A</strong>, split <strong>A</strong> in half into two subarrays, <strong>ALeft</strong> and <strong>ARight</strong>. Then recurse over these subarrays. Now, since we can assume they are sorted, iteratively merge <strong>ALeft</strong> and <strong>ARight</strong> into a single array, <strong>AFinal</strong>, by determining which subarray contains the next smallest element. In the end, return <strong>AFinal</strong>.</p><p>The recurrence relation is expressed as <strong>T(n) = 2T(n/2) + O(n)</strong>, allowing for a time complexity of <strong>O(nlog(n))</strong>.</p><p>This is significantly faster than sorting an array with brute force (O(n²)).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JbaisKIbVd-YuVpt" /><figcaption>Photo by <a href="https://unsplash.com/@edgr?utm_source=medium&amp;utm_medium=referral">Edu Grande</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Determine Your Base Algorithm</h3><p>First, decide which algorithm will lay most of the groundwork for your solution.</p><p>Generally, your solution will reduce a term <strong>n</strong> in the brute force time complexity to <strong>log(n)</strong>. So, think about the problem’s naive solution. In other words, how can the problem be solved with brute force, and what is that algorithm’s time complexity? If the naive solution runs in <strong>O(n)</strong> time, choose Binary Search, and if <strong>O(n²)</strong>, go with Merge Sort.</p><p>Using this trick, all that’s left is to alter these algorithms to fit your problem’s needs.</p><h3>Augmenting Binary Search</h3><ol><li>If the array to be searched is of infinite length, start by finding a finite value larger than the target. Start <strong>i</strong> at 1, then advance to 2, 4, 8, 16, etc until <strong>Array[i] &gt; target</strong>. This process requires <strong>O(log(n)) </strong>since indexes grow exponentially. Finally, perform Binary Search on <strong>Array[0..i]</strong>.</li><li>Ensure that the target value exists in the recursed subarray. This is inherently true when an array is sorted to be strictly ascending or descending. More complex cases do appear, like when <em>adjacent values in an unsorted array differ by at most 1</em>. As long as the target value is between the array’s first and last elements, recursing on the left ensures that the target exists in the range <strong>[start, middle)</strong> because the subarray must contain every discrete element between the bounds. The same is true when recursing on the right.</li><li>Ensure that the target value or condition is consistent with the array’s order property. For instance, finding the index, <strong>i</strong>, of an element, <strong>e</strong>, whose value satisfies <strong>e = 10 * i </strong>is only possible when ordered elements are each separated by at least 10.</li></ol><h3>Augmenting Merge Sort</h3><ol><li>Observe from which subarray merged elements come from. One classic example of this is seen when <a href="https://www.geeksforgeeks.org/counting-inversions/">determining the number of inversions in an array</a>. If the next element to be merged exists in the left subarray, then an inversion pair is found (intended order is inverted). Handle this by incrementing an eventually-returned counter variable.</li><li>Observe when the subarray containing the next merged element switches (i.e. left-to-right or right-to-left). Like before, this also exposes the lack or order in the original array. Tracking this behavior can be a useful tool when solving your problem.</li></ol><h3>Final Thoughts</h3><p>Divide and Conquer Algorithms have been perfected over the decades — If you’re tasked with building one from scratch, modeling your solution on a classic like Binary Search of Merge Sort is sure to put you on the right track.</p><p>Thanks for the read, and good luck dividing and conquering!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a187810cbd99" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/solve-any-divide-conquer-problem-with-this-trick-a187810cbd99">Solve Any Divide &amp; Conquer Problem With This Trick</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Containerization Isn’t Going Anywhere.]]></title>
            <link>https://codeburst.io/containerization-isnt-going-anywhere-81df3ae080cd?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/81df3ae080cd</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 12:03:46 GMT</pubDate>
            <atom:updated>2021-02-11T05:32:23.346Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why it’s here to stay for good</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vvUjTH5nuzG3SYRs" /><figcaption>Photo by <a href="https://unsplash.com/@carrier_lost?utm_source=medium&amp;utm_medium=referral">Ian Taylor</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I remember the days when I could simply deploy my code onto a Linux virtual machine and call the job done. <em>Those days are no more</em>.</p><p>Today, <a href="https://www.docker.com/resources/what-container"><strong>containerization</strong></a> is all the hype, and for good reason; it brings a shipment of power and flexibility to software development, deployment, and runtime. This can be applied to <em>any operation system, any machine, any project.</em></p><p>The most commonly used containerization technology is <a href="https://www.docker.com/"><strong>Docker</strong></a>. Let’s explore why it’s so useful and how it deviates from older methods.</p><h3>Virtual Machines vs. Containers</h3><p>In older times, server infrastructure (hardware) was divided into multiple virtual machines (VMs) via a hypervisor like <a href="https://www.vmware.com/products/vsphere-hypervisor.html"><strong>VMWare</strong></a>. This allows for the server’s resources (CPU, RAM, storage, etc) to be allocated among different guest operating systems, each representing a virtual machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aoRYlb1UhfHODoqQ4NOFgA.png" /><figcaption>Graphic courtesy of Author</figcaption></figure><p>Containerization introduces a more modern approach. Instead of partitioning a server into virtual machines, installing Docker on a single host operating system allows for multiple isolated containers to run at their own scale. These containers are fast and lightweight, as they can share common packages, binaries, and operating systems.</p><p>In short,<strong> VMs virtualize fixed hardware, while Containers virtualize the dynamic operating system</strong>.</p><h3>Networking</h3><h4>Distributed Applications</h4><p>One major benefit of containerizing applications is the ability to create a distributed network, or web of connected nodes. As a result, applications become horizontally scalable, where nodes can be added or subtracted at any time. In addition, the network enables fault tolerance. If one container goes down, the service is not lost; the other nodes in the network will carry the necessary weight until the outage is resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RXSV-VWtYTrisTuK" /><figcaption>Photo by <a href="https://unsplash.com/@dulgier?utm_source=medium&amp;utm_medium=referral">Nastya Dulhiier</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Networking also includes organizing containers into <a href="https://www.redhat.com/en/topics/microservices"><strong>microservices</strong></a>, each focusing on a specific task or responsibility. These distributed modules talk to each other, triggering events and passing data, to ensure the application is operational at large. Furthermore, each microservice can be a distributed system in itself, allowing for even greater flexibility.</p><h4>Container Orchestration</h4><p>Tools like <a href="https://kubernetes.io/"><strong>Kubernetes</strong></a> and <a href="https://docs.docker.com/engine/swarm/"><strong>Docker Swarm</strong></a> specialize in orchestrating a network of containers: automating processes, defining configurations, scheduling events, autoscaling clusters, load balancing, maintaining replicas, and more. With these tools, your orchestra of containers evolves into a symphony.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rc9RrDuIbI8bTHLf" /><figcaption>Photo by <a href="https://unsplash.com/@samthewam24?utm_source=medium&amp;utm_medium=referral">Samuel Sianipar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Deployment</h3><h4>Managed Cloud Containerization</h4><p>Your containerized application will eventually live in the cloud, likely hosted on AWS, Google Cloud, or Microsoft Azure. Sure, you can spin up a VM if you choose, but these providers make deploying your containers completely effortless. For instance, with <a href="https://aws.amazon.com/fargate/?whats-new-cards.sort-by=item.additionalFields.postDateTime&amp;whats-new-cards.sort-order=desc&amp;fargate-blogs.sort-by=item.additionalFields.createdDate&amp;fargate-blogs.sort-order=desc"><strong>AWS Fargate</strong></a>,<strong> </strong><a href="https://cloud.google.com/run"><strong>Google Cloud Run</strong></a>, and<strong> Azure </strong><a href="https://azure.microsoft.com/en-us/services/app-service/#product-overview"><strong>App Service</strong></a>, containerization is fully managed: <strong>upload the containers, and the rest is handled for you, hands free</strong>. This is ultimately minimal compared to redeploying a VM by manually starting your containers and microservices from the command line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sC37FMotoTj9VsvQ" /><figcaption>Photo by <a href="https://unsplash.com/@ismailenesayhan?utm_source=medium&amp;utm_medium=referral">İsmail Enes Ayhan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Compatibility with CI/CD</h4><p>Deploying containerized applications is even more seamless when leveraging <a href="https://www.redhat.com/en/topics/devops/what-is-ci-cd">Continuous Integration and Continuous Delivery</a><em> </em>(CI/CD). This means whenever code is pushed or merged in your repository, your containers can automatically redeploy to your web service. Setting up this essential automation takes minutes with a service like <a href="https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions"><strong>Github Actions</strong></a> and will save you hours down the road.</p><h3>Containerization is Future-Proof</h3><p>Since technology is continuously evolving, containerization will eventually be overthrown by another architecture, right? Wrong. Though the state of containerization today is not perfect, the practice of containerizing applications will not fade. The introduction of Containerization made virtualization more abstract since the operating system can be virtualized instead of low-level hardware. In fact, <strong>this pattern allows containers to be virtualized themselves, abstracting application environments even further</strong>.</p><p>When considering speed, practicality, organization, scalability, fault tolerance, and deployment, containerization beats virtual machines in every category. The main change the future will bring is further simplifying how microservices interact with one another. The three major cloud service providers already manage this for developers, and ease-of-use is only to improve in the future.</p><p>The benefits and features of Containerization mentioned in this article are only the tip of the iceberg. I strongly encourage you to read further and more thoroughly understand the true power and potential of virtualized containers.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81df3ae080cd" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/containerization-isnt-going-anywhere-81df3ae080cd">Containerization Isn’t Going Anywhere.</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Building New Projects You’ll Never Finish]]></title>
            <link>https://medium.com/@author-1/stop-building-new-projects-youll-never-finish-db80ae60c766?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/db80ae60c766</guid>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[passion]]></category>
            <category><![CDATA[aspirations]]></category>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[hobby]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 19:40:12 GMT</pubDate>
            <atom:updated>2021-01-10T19:40:12.450Z</atom:updated>
            <content:encoded><![CDATA[<h4>Chances are, your project won’t ever see the light of day</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vfFLDN2YmNRzuubY" /><figcaption>Photo by <a href="https://unsplash.com/@firmbee?utm_source=medium&amp;utm_medium=referral">William Iven</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Of course, I’m guilty of it too — Most of the projects I start never reach a formal release. In reality, most don’t even come close. As a software engineer, I found that for years, my Github profile resembled an abandoned shack instead of a flourishing home for my dozens of repositories.</p><p>Yet still, I manage to take on brand new side projects on a biweekly schedule. How is this possible? What drives this behavior, and how it can it be controlled?</p><h3>The Psychology of Desire</h3><p>Modern Desire Theory expresses that humans naturally want to reach a state where their desires are fulfilled. On a fundamental level, this means <strong>achieving personal happiness, success, or generating meaning</strong>.</p><p>All projects have aspirations that match at least one of those three goals. In the context of software development, this includes <strong>resolving a personal issue, building a career, earning revenue, or benefitting the greater developer community</strong>.</p><p>But what negative comes from aspiration? Let’s not forget that every identity is paired with its corresponding ego. This ego, first characterized by <a href="https://en.wikipedia.org/wiki/Sigmund_Freud">Sigmund Freud</a>, leads us to believe our goals are more attainable than they really are. As a result, we oftentimes overlook potential road blocks, structural issues, technical limitations, and other red flags that will prevent our projects from reaching production.</p><h3>Reasons for Abandonment</h3><p>It’s just as important to analyze and pinpoint <em>why</em> we let our projects stall.</p><h4><strong>1. Time is scarce</strong></h4><p>Life is busy, I get it. Sometimes side projects are a backup plan to a legitimate job, and always work comes first. Maybe your schedule is undergoing a shift and project work time is cut first. Either way, it is important to ensure that your life schedule has the stability to commit to such a project, or else it will inevitably be pushed to the side.</p><h4><strong>2. You just don’t care anymore</strong></h4><p>Projects can be just as trend-focused as fashion. When a new area of technology gains in popularity, you also want to join the wave. The excitement cannot be understated, as it feels like you’re reinventing computing. However, after a time, the glamour fades, and so does your interest in the project.</p><h4><strong>3. Another project came along</strong></h4><p>For eager beings like myself, this is the most common reason. After a few weeks, you had yet another project idea, and decided to act upon it. You promised yourself you would work on both projects simultaneously, but in reality, your old project was replaced, and will never be touched again.</p><h4><strong>4. You’re very, very stuck</strong></h4><p>All projects will throw you a curveball at some point. Some hurdles are easily overcome, but others lead your project to reach a devastating breaking point. For instance, if your project relies on a core technology that fails, your project would required an entire redesign. The intense frustration discourages you from continuing work on the project; you leave it behind altogether.</p><h3>How to Fight Project Abandonment Syndrome</h3><p>The key to building projects you’ll support, maintain, and expand for many years is <strong>passion</strong>. Your surroundings change all the time, more than you know; a deep passion for a topic, subject, or problem will not fade. If it does, <em>reconsider if it was a passion to begin with</em>.</p><p>A passion can take many forms. Do you have a strong dissatisfcation with the state of today? That’s a passion. Do you feel a calling towards an influencial career? That’s a passion. Is there a quality in the world you are desperate to see improved? That’s a passion. <strong>All you need to do is seek it out from within yourself</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pRTm3yYvv0YkT2_z" /><figcaption>Photo by <a href="https://unsplash.com/@tamarcusbrown?utm_source=medium&amp;utm_medium=referral">Tamarcus Brown</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>An Odyssey Backed by Passion</h3><p>Applying your passion in the right way will cause your project to become eternal. At this point, <strong>your project is not a <em>project</em>, but a journey</strong>; an odyssey with many milestones, but no finish line. This odyssey will not be interrupted, as any interference only adds another stage to the journey.</p><p>Many view projects as concrete, time-boxed deliverables. Sure, the argument can be made, but such <strong>projects are only worth your while if they constructive tie together somehow</strong>. Think of a deliverable project as one step on the staircase of your core mission. For instance, <a href="https://www.spacex.com/">SpaceX</a> prototypes multiple rockets in the pursuit of affordable space travel, and <a href="https://apple.com/">Apple</a> develops mobile devices to more fully integrate technology with everyday life.</p><p>In the same way, your projects should converge towards the vision you so critically want to make a reality. If this is not the case, your side-projects merely provide burdensome work, not a <strong>medium for your heart to speak</strong>.</p><p>Side-projects are food for curiosity, dedication, ambition, change, and the soul. Stop building fragmented, incomplete projects, and instead, <strong>work toward the impact you’re destined to make</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db80ae60c766" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coding Interview Question: Convert Roman Numerals to Decimals]]></title>
            <link>https://medium.com/better-programming/coding-interview-question-convert-roman-numerals-to-decimals-868b2694f497?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/868b2694f497</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Mon, 04 Jan 2021 16:23:23 GMT</pubDate>
            <atom:updated>2021-01-10T19:01:12.573Z</atom:updated>
            <content:encoded><![CDATA[<h4>Master this simple yet intimidating algorithm</h4><figure><img alt="Clock displaying Roman numerals" src="https://cdn-images-1.medium.com/max/1024/0*SliqKpiShOgZ4cnr" /><figcaption>Photo by <a href="https://unsplash.com/@thomasbormans?utm_source=medium&amp;utm_medium=referral">Thomas Bormans</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>I see this come up time and time again. Because the Roman numeral number system contains a tally-like, sometimes out-of-order layout, countless software engineers are intimidated when asked to programmatically convert from Roman numeral to decimal (base 10).</p><p>Anecdotally speaking, I’ve been given this task during coding interviews countless times, and it wasn’t until the third or fourth encounter that I confidently delivered an ace response.</p><p>Even though the question isn’t super complex, the stakes are high. This is typically meant to be a warm-up, with harder questions to follow. Therefore, it’s important that you do not immediately trip up and instead wow your interviewer with your analytical and technical skills.</p><p>If you’re in the market for a software engineering job, you’ll see this at some point — guaranteed. But don’t worry, I’ll walk you through a series of steps you can take to knock this question out of the park.</p><h3>Foundation and Approach</h3><p>Take some time to show your interviewer that you truly understand the nature of the problem. It is imperative that you explain how Roman numerals operate — especially how addition and subtraction can coexist within each numeral.</p><p>Remember that the basic numerals — not digits — once used by the Romans have tally values: I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000, and so on.</p><p>Then, explain in basic terms the process behind converting a number from Roman numeral to decimal. In case you’re unaware, this process goes as follows:</p><ol><li>Traverse the Roman numeral string from left to right, investigating two adjacent characters at a time. If you really want, specify that the direction of iteration does not matter as long as the comparisons (next step) are implemented accordingly.</li><li>If the character on the left is of higher ranking (tally value) than the character on the right, subtract the tally at that position from the final sum. Otherwise, add it.</li><li>After the string traversal is complete, the final sum represents the numeral’s modern counterpart.</li></ol><p>I’d even suggest white-boarding an example conversion. For instance, demonstrate how CMXCVIII yields the expression -100 + 1000 — 10 + 100 + 5 + 1 + 1 + 1 whose value is 998.</p><p>Building a foundation of understanding is crucial to your success. Oftentimes, your interviewer will even correct you if you’re straying toward the wrong path. There’s nothing your interviewer will hate more than you diving head-first into the coding without first investigating the problem at hand.</p><h3>The Code</h3><p>Remember that explanation (in words) of the algorithm? Time to translate it for the computer to understand.</p><p>First, define the tallies associated with each numeral for each numeral with a map using the given values:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b755f87996897425b89d4e1a7d45a4d/href">https://medium.com/media/5b755f87996897425b89d4e1a7d45a4d/href</a></iframe><p>You’ll also need to keep track of the numerals’ ongoing sum, starting at zero:</p><pre>sum = 0</pre><p>Now, iterate across the numeral string and extract the current pair of numerals. Be sure to iterate until the second-to-last numeral to prevent an out-of-bounds exception:</p><pre>for i in range(len(romanNumeral) - 1):<br>    left = romanNumeral[i]<br>    right = romanNumeral[i + 1]</pre><p>Make the pivotal comparison and add to/subtract from sum accordingly:</p><pre>    if tallies[left] &lt; tallies[right]:<br>        sum -= tallies[left]<br>    else:<br>        sum += tallies[left]</pre><p>Note that once you exit the for loop, the right-most numeral is not counted. We will account for this by updating the sum immediately after the for loop. Since there is no numeral to its right, addition is the only possibility in this case:</p><pre>sum += tallies[romanNumeral[-1]]</pre><p>That’s pretty much it! Just wrap the code in a callable function, return sum, and the code is ready to be run against test cases. With our implementation, the edge case of “” (empty string) as an input still provides the appropriate output of 0:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a16660073cfc9e27a469517472392956/href">https://medium.com/media/a16660073cfc9e27a469517472392956/href</a></iframe><h3>Theory and Analysis</h3><p>You can probably guess what comes next: Your interviewer asks, “What’s the Big-O?”</p><p>Since each character in the romanNumeral string must be traversed twice, the algorithm exhibits a best-case, average-case, and worst-case time complexity of O(n) or <em>linear time</em>. This is supported by the algorithm’s single for loop.</p><p>Your interviewer might also ask about <em>space complexity</em> or how memory usage grows with input size. Our function only uses memory to instantiate and update the variables sum, i, left, and right. All of these variables have one fixed-size instance regardless of the length of romanNumeral. Therefore, the algorithm’s space complexity is <em>constant</em> or O(1).</p><p>Since this solution is optimal, you can show off your skills even further by explaining why it’s optimal and what makes other methods inferior. To start, this solution processes each character once as a left numeral and once as a right numeral. Achieving a more efficient working solution is not possible. Also, we managed to build the function with a single loop, whereas solutions with multiple nested loops are held back by a time complexity above <em>linear time</em>. Stylistically, the code is readable, organized, and easy to follow. Pointing this out doesn’t hurt since the other side wants to make sure you understand real-world best practices.</p><p>Our Python implementation in its as-is form is faster than 92.08% of submissions to <a href="https://leetcode.com/problems/roman-to-integer/">LeetCode’s assessment</a>, with a memory usage below 72.29% of all submissions. I encourage you to make more improvements and have a stab at rising higher through these percentiles on your own.</p><p><a href="https://leetcode.com/problems/roman-to-integer/">Roman to Integer - LeetCode</a></p><h3>Conclusion</h3><p>As always, happy coding and good luck with your interview!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=868b2694f497" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/coding-interview-question-convert-roman-numerals-to-decimals-868b2694f497">Coding Interview Question: Convert Roman Numerals to Decimals</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate Mac Workflows with Quick Actions on Touch Bar]]></title>
            <link>https://medium.com/macoclock/automate-mac-workflows-with-quick-actions-on-touch-bar-61932ac1b633?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/61932ac1b633</guid>
            <category><![CDATA[macos]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[touch-bar]]></category>
            <category><![CDATA[applescript]]></category>
            <category><![CDATA[mac]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Wed, 30 Dec 2020 08:44:55 GMT</pubDate>
            <atom:updated>2020-12-30T08:44:55.583Z</atom:updated>
            <content:encoded><![CDATA[<h4>And no, you don’t need to be a developer</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gm8yCIRg_9gA4A_8iyLc9w.png" /><figcaption>Altered image from <a href="https://commons.wikimedia.org/wiki/File:Touch_bar_of_15%22_MacBook_pro.jpg">Wikimedia Commons</a> under <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons License</a></figcaption></figure><p>I live by a simple rule —<strong> If a task requires more than five minutes per day, spend five minutes automating it</strong>. Rarely do I ever break this rule, and for good reason.</p><p>Automation has completely reshaped how I use my mac; the personalization, time savings, simplicity, and ultimate power at my fingertips is more clear than ever before. For example, many of my machine’s automations include <em>app and window management, batch file operations, automatic email communications</em>, and the list keeps growing every week.</p><p>One major talking point of iOS 14 is pinning automations to the home screen. Despite the hype, <strong>this feature has been available for MacBook Pro users since the release of macOS Mojave in 2018!</strong></p><h4>Objective</h4><p>I have a bad habit of keeping an unreasonably large number of Safari tabs open at once. In this tutorial, I will be building an automated workflow that simplifies my safari workspace into a few, predefined tabs.</p><h3>Introduction to Automator</h3><p>Every Mac ships with an application called Automator. You can find it under /Applications/Utilities/ or by searching for it with Spotlight (⌘ Space). Once open, create a new automation (⌘ N), and select Quick Action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cX1VjaYv4Llp_UinYBph4w.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><p>Before we define the workflow, the automation requires some set-up. We first declare that this workflow will not recieve any input and can be run while in any application. We also choose an icon and color for our Quick Action. Finally, save the automation (⌘ S)and give it a name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jU4S8SpHMVHK5rEkPgBhFg.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><p>Automator is full of handy features. The Actions Library (left) hosts a thorough list of pre-built actions your workflow can utilize by dragging into the workspace. One of my favorite features, though, is the record button (top right), which observes all actions you commit on your Mac and translates it to repeatable system events.</p><h3>Building the Workflow</h3><h4>AppleScript</h4><p>The first action we will include is <strong>Run AppleScript</strong>. Sure, nobody knows AppleScript by heart, but there are just enough snippets on the internet for you to find your way. Here’s a quick script I found on Google that closes every Safari window currently open.</p><pre>on run {input, parameters}<br>    tell application &quot;Safari&quot;<br>        close every window<br>    end tell<br>    return input<br>end run</pre><p>Here’s the action in Automator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hkhhQcktStZe4OwlQAbtA.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><h4>Opening Tabs</h4><p>Next, we’ll use the <strong>Get Specified URLs</strong> action to indicate which websites to open. In my case, I want to open my personal website, GitHub, Yahoo Finance, LinkedIn, and of course, Medium.</p><p>Then, lets implement the <strong>Display Webpages</strong> action, which will automatically take the list of URLs from the previous action as input.</p><p>Put it all together, and we get this workflow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7dz6lFWEJ120F5qI8Mbh3A.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><p><strong>Don’t forget to save!</strong></p><h3>Adding Quick Action to Touch Bar</h3><p>This process is incredibly simple, since it is native to macOS. There are no third party downloads or other hoops to jump through.</p><p>In <strong>System Preferences</strong>, navigate to <strong>Extensions/Touch Bar</strong>, and you should see a list of your Quick Actions. Make sure to check every Quick Action you want to appear on your Touch Bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R9hb7dH1AV4lLWAIvGXwAg.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><p>After that, click <strong>Customize Control Strip…</strong> and drag the <strong>Quick Actions</strong> button onto your Touch Bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhAL3hX8YnDnSJyQTusDAQ.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><p>My Touch Bar’s control strip now has this configuration:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qOWCy0_b4qPiNjUdmytDKA.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><p>Pressing this icon will open a new menu on the Touch Bar with all our Quick Actions. Just pressing these buttons will trigger the corresponding workflow. One touch, that’t it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PlGuYIMMzwoP-7joLpH_Dw.png" /><figcaption>Screenshot from Author’s MacBook Pro with Touch Bar</figcaption></figure><h3>Our Automation in Action</h3><p>Upon pressing the <strong>Simple Safari </strong>button we added to the Touch Bar, Safari reduces to my 5 essential tabs. 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*p1o82e1hiMw3tuoSMxTLVQ.gif" /><figcaption>Screen Recording from Author’s MacBook Pro with Touch Bar</figcaption></figure><h3>Conclusion</h3><p>There are an endless number of ways you can leverage Automator for your needs. Pre-built actions allow all mac users, beginner and advanced, to construct robust workflows of any scale. I encourage you to play around with the application and find more ways to further personalize your machine, all while saving time in the long run.</p><p><em>Quick Actions are just the tip of the iceberg when it comes to Automator</em>. If you’re truly in love with automation like me, explore Automator’s other presets and tools, and continue to find ways to simplify how you interact with technology.</p><p>Remember, <strong>if a task requires more than five minutes per day, spend five minutes automating it.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61932ac1b633" width="1" height="1" alt=""><hr><p><a href="https://medium.com/macoclock/automate-mac-workflows-with-quick-actions-on-touch-bar-61932ac1b633">Automate Mac Workflows with Quick Actions on Touch Bar</a> was originally published in <a href="https://medium.com/macoclock">Mac O’Clock</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Computing PI in Only 3 Lines]]></title>
            <link>https://medium.com/data-science/computing-pi-in-only-3-lines-95c26276f4c9?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/95c26276f4c9</guid>
            <category><![CDATA[calculus]]></category>
            <category><![CDATA[precision]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[taylor-series]]></category>
            <category><![CDATA[pi]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Mon, 21 Dec 2020 18:13:01 GMT</pubDate>
            <atom:updated>2020-12-21T18:13:01.045Z</atom:updated>
            <content:encoded><![CDATA[<h4>3.1415… the rest is calculus with a keyboard</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q0-4Oir7bMRMV1rL" /><figcaption>Photo by <a href="https://unsplash.com/@sheri_silver?utm_source=medium&amp;utm_medium=referral">sheri silver</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I’ve always been amazed by how precisely computers can approximate Pi: the famous irrational constant 3.141592… plus infinitely more digits. Today, over 50 trillion digits have been found.</p><p>Though the value of Pi is essential to nature, Pi does not come naturally to computers. A number of algorithms are commonly used to approximate Pi, including the <a href="https://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_algorithm">Gauss–Legendre</a>, <a href="https://en.wikipedia.org/wiki/Borwein%27s_algorithm">Borwein’s</a>, and <a href="https://en.wikipedia.org/wiki/Salamin%E2%80%93Brent_algorithm">Salamin–Brent</a> algorithms. These methods are extraordinarily efficient, but somewhat complex.</p><h3>A More Straightforward Approach</h3><p>There is one method — one that I discovered on my own in high school — that <strong>isn’t as fast, but is most elegant in its simple mathematic groundwork</strong>.</p><p>In calculus class, you probably studied the <a href="https://en.wikipedia.org/wiki/Taylor_series"><strong>Taylor Series</strong></a>: an infinitely long summation that can model any function by matching all derivatives up to the nth degree. Our goal is to find the right Taylor Series such that the infinite summation converges to Pi itself.</p><p>Let’s start with a basic trig expression involving Pi.</p><pre>1 = tan(π / 4)</pre><p>Rearranging this equation allows us to solve directly for Pi.</p><pre>π = 4 * arctan(1)</pre><p>Though I won’t walk through the formal derivation, the Taylor Series for 4 * arctan(1) is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8yJFKTm-jBda4B9GYD5WVw.png" /><figcaption>Image by Author</figcaption></figure><p>which can be written in summation notation as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_K_MI6bh09LgLX8D0eRWWQ.png" /><figcaption>Image by Author</figcaption></figure><p>As you can see, this definition of Pi finds its beauty in its simplicity.</p><h3>Translating to Code (Python)</h3><p>The formal summation we found falls hand-in-hand with modern programming methods, as the sigma is really a <strong>for-loop in disguise</strong>.</p><p>Amazingly, the summation itself only requires 3 lines of code! A variable pi holds the current sum, as new terms of the series are added on loop.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adf151269e5c3b58c87b91e7c493173c/href">https://medium.com/media/adf151269e5c3b58c87b91e7c493173c/href</a></iframe><p>Though the above program is functional, the exponentiation runtime grows proportionally with i. An easy fix is using modulus to determine the next term’s sign.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90223cdc9ecc43e86cbd81c9c0186f1a/href">https://medium.com/media/90223cdc9ecc43e86cbd81c9c0186f1a/href</a></iframe><h3>Convergence and Algorithm Efficiency</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WzEWMZVfbpvByt7riG3WRA.png" /><figcaption>Image by Author</figcaption></figure><p>The approximation converges to Pi with increasing iterations, as visualized in this graph. Also, due to the alternating signs between terms, the approximation constantly jumps across Pi’s exact value, with each error bound being less than the previous.</p><p>Equally interesting is how the approximation’s accuracy increases with the number of iterations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zJRkX3RwwK4iXD6ce0SOnA.png" /><figcaption>Image by Author</figcaption></figure><p>When analyzing how many iterations are required various digit of precision, I <em>accidentally discovered</em> that <strong>every new digit of precision occurs after the summation of 2 times a power of 10 terms</strong> (amazing coincidence, right?)!</p><p>The first digit, 3, is finalized after 2 = 2 * 10⁰ iterations, since the approximation of 2.67 is within 0.5 of Pi’s exact value. The second digit, 1, is set in stone after 20 = 2 * 10¹ iterations because 3.0916 is within 0.05 of Pi’s exact value. Following this trend, the 4 occurs after the summation of 200 terms, then the 1 after 2000 terms, then the 5 after 20,000 terms, and so on.</p><p>As exemplified by this trend, the <strong>number of operations needed to generate digits of pi grows exponentially with every digit</strong>; each digit requires 10 times more computation than the previous.</p><h3>Increasing Precision</h3><p>Most programming languages offer a 32-bit and 64-bit (Double) floating-point type, allowing for 7 and 16 digits of precision respectively. In other words, <strong>3.141592653589793 is the probably the best approxmimation you can make out-of-the-box</strong>.</p><p>The C languages offer a Quadruple-precision floating-point type, <strong>__int128</strong>, boasting up to 36 digits of precision.To compute an approximation with arbitrary (dynamic) precision, look into <strong>Java’s </strong><a href="https://www.geeksforgeeks.org/bigdecimal-class-java/"><strong>BigDecimal</strong></a><strong> class</strong>.</p><p>Keep in mind that though languages like C and Java execute much faster than interpreted languages like Python, using larger floating-point primitives or dynamic data structures can slow down execution drastically.</p><h3>Conclusion</h3><p><em>If you want to earn the new world record for discovering the most digits of Pi, this method is not for you.</em></p><p>However, the algorithm outlined here is <strong>unique in its pure simplicity and mathematical elegance</strong>. Computer science is nothing but math with a keyboard, allowing us to further understand the natural world with our man-made machines.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95c26276f4c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/computing-pi-in-only-3-lines-95c26276f4c9">Computing PI in Only 3 Lines</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The O(n) Sorting Algorithm of Your Dreams]]></title>
            <link>https://codeburst.io/the-o-n-sorting-algorithm-of-your-dreams-d2dd31b06848?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2dd31b06848</guid>
            <category><![CDATA[efficiency]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[big-o-notation]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Fri, 18 Dec 2020 17:34:05 GMT</pubDate>
            <atom:updated>2020-12-18T17:34:05.817Z</atom:updated>
            <content:encoded><![CDATA[<h4>Explore the genius behind LSD Radix Sort</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8V3BhaLgQYh8-OkYYuMc0Q.jpeg" /><figcaption>Image sourced from Pexels</figcaption></figure><p>Sorting algorithms are by no means time efficient. As software engineers, we begin by learning basic sorts, like <a href="https://www.geeksforgeeks.org/bubble-sort/"><strong>Bubble Sort</strong></a>, <a href="https://www.geeksforgeeks.org/insertion-sort/"><strong>Insertion Sort</strong></a>, and <a href="https://www.geeksforgeeks.org/selection-sort/"><strong>Selection Sort</strong></a>. Later on, we pick up more advanced sorts, like <a href="https://www.geeksforgeeks.org/heap-sort/"><strong>Heapsort</strong></a>, <a href="https://www.geeksforgeeks.org/quick-sort/"><strong>Quicksort</strong></a>, and <a href="https://www.geeksforgeeks.org/merge-sort/"><strong>Mergesort</strong></a>. Still, most of those algorithms have a worst-case time complexity, or Big-O, of O(n²), with the other few being O(nlogn)— O(n) is nowhere to be seen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_YH5DKLJlA6ndWKmyid0w.png" /><figcaption>Infographic from <a href="https://www.bigocheatsheet.com/">Big-O Cheat Sheet</a></figcaption></figure><h4>Introducing LSD Radix Sort</h4><p>For a sorting algorithm to have a time complexity of O(n), there surely needs to be a spark of genius behind it all. Unlike other sorting algorithms, LSD Radix Sort is <strong>non-comparative</strong> and only utilizes <strong>hashing</strong> (O(1) amortized) and simple traversals (O(n)); put these two ingredients together, and you have a worst-case O(n) sorting algorithm!</p><p>In a nutshell, Least Significant Digit (LSD) Radix Sort involves repeatedly sorting the digits that occur in each element. Assuming we are sorting a lexicographical (numerical) type, this means we order by the ones place, then the tens place, then the hundreds, thousands, etc. while always maintaining the order previously established.</p><h3>Algorithm Breakdown</h3><p>Enjoy this line-by-line walkthrough in Python, or if you’re a C++ developer, <em>pseudocode</em>.</p><p>First, we need to find how many iterations are necessary for sort the list. This is easily accomplished by traversing the list and finding the maximum number of digits that make up any one element.</p><pre>numIterations = 0<br>for element in list:<br>    numIterations = max(numIterations, int(math.log10(element))+1)</pre><p><strong>Then comes the core of the algorithm.</strong></p><p>Iterating numIterations times, we need to get the current number’s place from which to sort.</p><pre>for i in range(0, numIterations):<br>    place = 10 ** i</pre><p>Every iteration, we need to populate a<strong> </strong><a href="https://www.geeksforgeeks.org/hashing-set-2-separate-chaining/"><strong>separate chaining</strong></a> map. The keys of this map are all positive and negative digits, -9 through 9, which are commonly referred to as buckets The corresponding values are all initialized as empty lists.</p><pre>map = {}<br>for i in range(-9, 10):<br>    map[i] = []</pre><pre># { -9: [], -8: [], -7: [], ... , 7: [], 8: [], 9: [] }</pre><p>Let’s find the digit at the current number’s place for each element and append that element to the corresponding bucket. If the element does not contain enough significant digits, the 0 bucket is used.</p><pre>for element of list:<br>    bucket = (element // place) % 10<br>    map[bucket].append(element)</pre><p>Next, let’s perform an in-order traversal of the map, effectively dumping the map into a list sorted according to the current number’s place. <em>Note that the previous order is preserved because elements populate the separate chained lists in the order they are encountered.</em></p><pre>currentIndex = 0<br>for elements in map.values():<br>    for element in elements:<br>        list[currentIndex] = element<br>        currentIndex += 1</pre><p>That’s it! The algorithm will repeat this process until the list is sorted.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca63a0b9b106072322845a27df75cba6/href">https://medium.com/media/ca63a0b9b106072322845a27df75cba6/href</a></iframe><h3>Tracing Example</h3><p>To further understand how LSD Radix Sort manipulates an unsorted list, let’s walk through an example.</p><p>Imagine we start with a list [45, 986, 24, 3000, 7, 43, -1000, 949]. Immediately, we know that the algorithm will require 4 iterations, since 3000 and -1000 contains 4 digits.</p><p>During the first iteration (order by one’s place), the elements form the following map</p><pre>{<br>  0: [300<strong>0</strong>, -100<strong>0</strong>],<br>  3: [4<strong>3</strong>],<br>  4: [2<strong>4</strong>],<br>  5: [4<strong>5</strong>],<br>  6: [98<strong>6</strong>],<br>  7: [<strong>7</strong>],<br>  9: [94<strong>9</strong>]<br>}</pre><p>which when traversed, results in the list [3000, -1000, 43, 24, 45, 986, 7, 949].</p><p>Let’s <strong>rinse and repeat for the remaining three iterations</strong>.</p><p>Iteration 2 (tens place):</p><pre>{<br>  0: [30<strong>0</strong>0, -10<strong>0</strong>0, 7],<br>  2: [<strong>2</strong>4],<br>  4: [<strong>4</strong>3, <strong>4</strong>5, 9<strong>4</strong>9],<br>  8: [9<strong>8</strong>6]<br>}</pre><pre>[3000, -1000, 7, 24, 43, 45, 949, 986]</pre><p>Iteration 3 (hundreds place):</p><pre>{<br>  0: [3<strong>0</strong>00, -1<strong>0</strong>00, 7, 24, 43, 45],<br>  9: [<strong>9</strong>49, <strong>9</strong>86]<br>}</pre><pre>[-1000, 7, 24, 43, 45, 949, 986]</pre><p>Iteration 4 (thousands place):</p><pre>{<br>  -1: [<strong>-1</strong>000],<br>  0: [7, 24, 43, 45 949, 986],<br>  3: [<strong>3</strong>000]<br>}</pre><pre>[-1000, 7, 24, 43, 45, 949, 986, 3000]</pre><p>Voila! After 4 iterations, the unsorted list[45, 986, 24, 3000, 7, 43, -1000, 949] transforms into the sorted list[-1000, 7, 24, 43, 45, 949, 986, 3000].</p><h3>Big-O != Efficiency</h3><p>Sure, LSD Radix Sort is the most efficient sorting algorithm — <em>on paper</em>.</p><p>There’s a major difference between technical time complexity and real-world efficiency. Big-O, for the most part, ignores constants and focuses on the function’s growth. In practice, the constants not present in Big-O notation make a significant difference in program runtime, since the number of total operations is what really matters.</p><h4>So How Efficient is LSD Radix Sort, Really?</h4><p>Taking constants into account, this algorithm has a time complexity of O(mn), where n is list length, and m is the average element length (number of radices). This makes sense since the map traversal uses n operations, and this whole process must be repeated through m iterations.</p><h3>When to Use LSD Radix Sort</h3><p>When m is very small, LSD Radix Sort is at its prime. This is when the number of hashing iterations and traversals is minimized.</p><p>On the other hand, if m is large, then LSD Radix Sort will have a proportionately long runtime. To put this scenario into perspective, as m approaches n, Big-O approaches O(n²): exactly the inefficiency we wanted to avoid in the first place. If this is the case, it is worth considering implementing Mergesort or Heapsort, whose worst-case time complexities are O(nlogn).</p><h3>Conclusion</h3><p>Thanks for reading my article, I hope you’ve found it helpful. Feel free to leave feedback or questions in the comments section.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2dd31b06848" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/the-o-n-sorting-algorithm-of-your-dreams-d2dd31b06848">The O(n) Sorting Algorithm of Your Dreams</a> was originally published in <a href="https://codeburst.io/">codeburst</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[There’s no Harm in Slowly Migrating to React.js (Start ASAP)]]></title>
            <link>https://medium.com/swlh/theres-no-harm-in-slowly-migrating-to-react-js-start-asap-b36bddccc60e?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/b36bddccc60e</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Sat, 12 Dec 2020 23:56:21 GMT</pubDate>
            <atom:updated>2020-12-14T06:52:18.965Z</atom:updated>
            <content:encoded><![CDATA[<h4>For this reason, it’s always a good time to start folding your static HTML / CSS / JS webpages into a React.js web app</h4><figure><img alt="Funneling HTML, CSS, and JavaScript into React.js" src="https://cdn-images-1.medium.com/max/960/1*ulD6na_hQsXA5uC0acoteA.png" /><figcaption>Image by <a href="https://ed.team/@alvaro">Alvaro Felipe</a> on <a href="https://ed.team/blog/como-funciona-reactjs">ed.team</a></figcaption></figure><p>I’m not the first to admit it — I should have migrated my HTML / CSS / JS / jQuery site to React.js a long time ago. On the verge of 2021, the reasons are clear; React allows for better organization, truly reusable components, powerful routing, Server-Side Rendering (SSR), Static Site Generation (SSG), modern web features, and more.</p><p>Still, it definitely wasn’t my first thought to jump ship to React. As my site grew in complexity and scale, manually editing dozens of .html files became inconvenient, but the thought of learning a new framework was more daunting. According to computer science proverbs, <em>if it ain’t broken, why fix it</em>, right?</p><p>Wrong. In fact there is hardly any consequence to migrating your website to React.js incrementally, at your own pace.</p><h3>Step 1: Create your React Web App</h3><p>At this point, you‘re probably worried about how to set up your site in the first place. Luckily, the work is done for us, thanks to <a href="https://github.com/facebook/create-react-app"><strong>create-react-app</strong></a><strong>!</strong></p><p><strong>Note</strong>: feel free to use <strong>Next.js for SSR</strong>, or <strong>Gatsby.js for SSG</strong></p><p>On your machine, initialize your React project with</p><pre>npx create-react-app your-website</pre><p>This will populate a directory <strong>your-website </strong>with all the resources you need to get up and running. Voila!</p><pre>your-website<br>├── README.md<br>├── package-lock.json<br>├── package.json<br>├── public<br>│   ├── favicon.ico<br>│   ├── index.html<br>│   ├── manifest.json<br>│   └── robots.txt<br>└── src<br>    ├── App.css<br>    ├── App.js<br>    ├── index.css<br>    ├── index.js<br>    └── logo.svg</pre><p>Notice that two directories are created: <strong>/src </strong>and <strong>/public</strong>.</p><p><strong>/src</strong> is the main home of the React app itself. Here, you will write components, assemble pages, configure routers, etc.</p><p><strong>/public</strong> is the home of all static content. This means images, sitemaps, your robots.txt and manifest.json files (as visualized), and you guessed it — static standalone webpages.</p><h3>Step 2: Integrate Your Existing Webpages</h3><p>Now that we’ve established /public to be the parent directory to our current static website, let’s drop in those files and directories.</p><p>Imagine I have 3 webpages: <em>about</em>, <em>shop</em>, and <em>contact</em>. Each is a directory that contains .html, .css, and .js files. I also have a background image, sitemap, and terms and conditions document.</p><p>Dropping these files into the public folder leads to the following structure:</p><pre>your-website<br>├── README.md<br>├── package-lock.json<br>├── package.json<br>├── public<br>│   ├── about<br>│   │   ├── functions.js<br>│   │   ├── index.html<br>│   │   └── styles.css<br>│   ├── background.jpg<br>│   ├── contact<br>│   │   ├── functions.js<br>│   │   ├── index.html<br>│   │   └── styles.css<br>│   ├── favicon.ico<br>│   ├── index.html<br>│   ├── manifest.json<br>│   ├── robots.txt<br>│   ├── shop<br>│   │   ├── functions.js<br>│   │   ├── index.html<br>│   │   └── styles.css<br>│   ├── sitemap.xml<br>│   └── terms.pdf<br>└── src<br>    ├── App.css<br>    ├── App.js<br>    ├── index.css<br>    ├── index.js</pre><p><strong>Note</strong>: Remember to link any static files from inside the root index.html file, if applicable.</p><h3>Step 3: Verify your Static Routes in the Browser</h3><p>On your machine, start serving the web app over localhost with</p><pre>npm run start</pre><p>This should take you to this interface:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m48paqI7bGW2RpXdaadwGg.png" /><figcaption>Resulting webpage after the command <strong><em>npm run start</em></strong></figcaption></figure><p>This is your homepage. Remember the static index.html file create-react-app generated for you? That’s what you’re seeing! When your React app is built, its components will populate that index.html file, bringing the boilerplate to life.</p><p>To test your static routes, visit them through the browser’s url bar.</p><p>Remarkable! The urls <strong>localhost:3000/about</strong>, <strong>localhost:3000/shop</strong>, and <strong>localhost:3000/contact</strong> all appear and act as they did before.</p><p>This is crucial to your migration because the static standalone webpages you provided <em>do not affect</em> the React app itself. In other words, <strong>both styles of web development can coexist on the same domain.</strong></p><p>Furthermore, the timeline of your site’s migration is entirely up to you. As you begin to learn more about React.js with time, you can slowly morph these .html files into React components using tag-based <a href="https://reactjs.org/docs/introducing-jsx.html"><strong>JSX</strong></a>. On the other hand, you can choose to never bother with migrating the static webpages, and simply start publishing your future pages with React. The choice is all yours!</p><h3>That Sounds Great, but What’s the Catch?</h3><p>I knew this process sounded too good to be true. All described above is accurate, but there is one potential pitfall: Your root webpage (www.your-website.com/) needs to be built with React.</p><p>Still, it’s not the end of the world; for most cases, this only requires changing the placeholder code in src/App.js to fit your needs. React has incredible <a href="https://reactjs.org/docs/getting-started.html"><strong>documentation</strong></a>, and the web is an infinite hive of tutorials, blog posts, and other resources.</p><p><strong>Put simply, since you’ve already committed to learning and using React.js, building your homepage with it should not stand in your way.</strong></p><h3>Conclusion</h3><p><strong>Is migrating your static HTML / CSS / JS / jQuery page to React.js a flawless process? Not entirely.</strong></p><p><strong>Should you still undergo the migration as soon as possible? Absolutely.</strong></p><p>Static web development is an acceptable practice… for now. As web technologies evolve, you’re going to want your framework to keep up. For those reasons, migrating to React.js is the obvious choice.</p><p>Your static webpages are only a short term solution; slowly moving your codebase to a modern framework at your own pace will help future-proof your web application for the next ten years, with no sweat or tears involved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b36bddccc60e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/theres-no-harm-in-slowly-migrating-to-react-js-start-asap-b36bddccc60e">There’s no Harm in Slowly Migrating to React.js (Start ASAP)</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Easily Verbalize Any C Variable Type Declaration]]></title>
            <link>https://medium.com/swlh/how-to-easily-verbalize-any-c-variable-type-declaration-2c705166557c?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c705166557c</guid>
            <category><![CDATA[declaration]]></category>
            <category><![CDATA[arrays]]></category>
            <category><![CDATA[c-language]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[pointers]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Sun, 29 Nov 2020 18:49:11 GMT</pubDate>
            <atom:updated>2020-12-19T09:59:13.237Z</atom:updated>
            <content:encoded><![CDATA[<h4>Here’s a couple of pointers.</h4><p>Part of what makes C incredibly powerful is its complex type declarations. These statements can become infinitely complex, making it a necessity that we know how to express them into plain English.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1zdDsp5HU74xy5xSHvctg.png" /><figcaption><em>A sample complex C variable type declaration</em></figcaption></figure><p>Like in most things programming, this is done by merely following an algorithm.</p><h4>1. Identify and Locate the Variable Name</h4><p>This is typically a name within the type declaration that is not a <a href="https://beginnersbook.com/2014/01/c-keywords-reserved-words/"><em>reserved word</em></a><em>.</em></p><h4>2. Move Left to Traverse Pointers</h4><p>From the position of the variable name, move left until you read an opening parenthesis, ‘<strong>(</strong>‘, or the start of the type declaration, exluding the left-most type. For every ‘<strong>*</strong>’ you encounter, add the term “pointer to” to the variable declaration.</p><h4>3. Move Right to Traverse Arrays and Functions</h4><p>Resuming from the end of step 2, move right until you read a closing parenthesis, ‘<strong>)</strong>’, or the end of the variable declaration.</p><p>If you encounter brackets, add “array of length {<em>length</em>} of“ to the type declaration.</p><p>If you encounter parentheses, there are three possibilities:</p><ol><li>If the parentheses are empty, ‘<strong>()</strong>’, add “a function with unknown parameters returning” to the declaration.</li><li>If the parentheses read ‘<strong>(void)</strong>’, add “a function with taking no parameters returning”.</li><li>Otherwise, add “a function taking ({<em>list param types</em>}) returning”.</li></ol><h4>Repeat steps 2 and 3 until you have reached both ends of the variable declaration.</h4><h4>4. Recognize Final Type</h4><p>Finally, add the left-most type to the variable’s type declaration. This is always a reserved type, struct, union, or class, or other pre-defined type.</p><h3>Example</h3><p>Imagine we want to verbalize the following variable declaration:</p><pre><strong>char (*(**foo)[3])[10);</strong></pre><pre>Step 1: &quot;Declare foo to be of type&quot;<br>Step 2: &quot;pointer to pointer to&quot;<br>Step 3: &quot;array length 3 of&quot;<br>Step 2 (repeat): &quot;pointer to&quot;<br>Step 3 (repeat): &quot;array length 10 of&quot;<br>Step 4: &quot;char&quot;</pre><p>In the end, we find that</p><pre><strong>char (*(**foo)[3])[10);</strong></pre><p>means</p><p><em>Declare foo to be of type pointer to a pointer to array length 3 of pointer to array length 10 of char.</em></p><h3>More Difficult Example</h3><pre><strong>unsigned int (*(**(*foo)(int , volatile short ))[4][6])[8];</strong></pre><pre>Step 1: &quot;Declare foo to be of type&quot;<br>Step 2: &quot;pointer to&quot;<br>Step 3: &quot;function taking (int, volatile short) returning&quot;<br>Step 2 (repeat): &quot;pointer to pointer to&quot;<br>Step 3 (repeat): &quot;array length 4 of array length 6 of&quot;<br>Step 2 (repeat): &quot;pointer to&quot;<br>Step 3 (repeat): &quot;array length 8 of&quot;<br>Step 4: &quot;unsigned int</pre><p><em>Declare foo to be of type pointer to function (int, volatile short) returning pointer to pointer to array length 4 of array length 6 of pointer to array length 8 of unsigned int.</em></p><h3>Try for Yourself</h3><p>Play around with <a href="http://cdicl.org/">this awesome tool</a> to practice your C variable declaration verbalization skills!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c705166557c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-easily-verbalize-any-c-variable-type-declaration-2c705166557c">How to Easily Verbalize Any C Variable Type Declaration</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Java’s Everyday System.out.println();]]></title>
            <link>https://medium.com/@author-1/understanding-javas-everyday-system-out-println-799724149710?source=rss-8d1a76d48b32------2</link>
            <guid isPermaLink="false">https://medium.com/p/799724149710</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[hello-world]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[print]]></category>
            <dc:creator><![CDATA[Author]]></dc:creator>
            <pubDate>Sun, 29 Nov 2020 07:14:27 GMT</pubDate>
            <atom:updated>2020-12-16T23:52:46.109Z</atom:updated>
            <content:encoded><![CDATA[<h4>You used it for “Hello World”, but do you understand its true meaning?</h4><p><a href="https://www.geeksforgeeks.org/system-out-println-in-java/"><strong>System.out.println()</strong></a>, or S.O.P, is <a href="https://en.wikipedia.org/wiki/Java_(programming_language)">Java’s</a> most commonly used printing function.</p><p>Let’s break it down further using our understanding of the language and more general OOP concepts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*ihSYTw1xfPiIAqMzBf4g6g.png" /></figure><h4><strong>1. System</strong></h4><p><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/System.html"><em>System</em></a> is a class located in the <strong>java.lang.System</strong> package.</p><p>Though it cannot be instantiated directly due to its private constructor, it houses capabilities regarding standard IO, error streams, environment, the filesystem, and more.</p><h4>2. out</h4><p><a href="https://docs.oracle.com/javase/7/docs/api/java/lang/System.html"><em>out</em></a> is a static field of the System class.</p><p>Note that its static nature means it can be accessed without instantiating System, just like Math.PI.</p><p>out is of type <a href="https://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html"><strong>PrintStream</strong></a>, allowing it to output data to the “standard” output stream at any point. In most cases, this occurs in the form of displaying text in the environment’s command prompt.</p><h4>3. printLn()</h4><p><a href="https://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html"><em>printLn()</em></a> is a void method that outputs its parameter to the output stream, as previously described.</p><p>In typical Java fashion, printLn() is overloaded to accept multiple types, such as String, boolean, char, int, long, double, Object, etc.</p><p>A similar function, print(), belongs to the Out field that accomplishes the same purpose, but does not append the newline (‘\n’) character to the output stream.</p><h3>It’s all OOP</h3><p>Interesting… diving deeper into one of Java’s most fundamental functions leads us to encounter several core concepts of <a href="https://en.wikipedia.org/wiki/Object-oriented_programming"><strong>Object Oriented Programming (OOP)</strong></a>: Constructors, Visibility Modifiers, Static Fields, Overloading, and even more not mentioned here.</p><p>I challenge you to critically inspect your favorite language, finding how its design and architecture is showcased within code segments that are taken for granted.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=799724149710" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>