<?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 Tushar Sadana on Medium]]></title>
        <description><![CDATA[Stories by Tushar Sadana on Medium]]></description>
        <link>https://medium.com/@tusharsadana?source=rss-3dd267c408f9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gGVCEshtSwUvjX1o2Rx1AQ.jpeg</url>
            <title>Stories by Tushar Sadana on Medium</title>
            <link>https://medium.com/@tusharsadana?source=rss-3dd267c408f9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:07:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tusharsadana/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[Twitter’s Scalability Odyssey: From “Fail Whale” to Flawless Performance and How can you do…]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">This blog talks about how Twitter implemented scalability techniques and how you can do something similar for yourself.</p><p class="medium-feed-link"><a href="https://medium.com/swlh/twitters-scalability-odyssey-from-fail-whale-to-flawless-performance-and-how-can-you-do-922aa71e83fb?source=rss-3dd267c408f9------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/twitters-scalability-odyssey-from-fail-whale-to-flawless-performance-and-how-can-you-do-922aa71e83fb?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/922aa71e83fb</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Fri, 15 Sep 2023 09:29:03 GMT</pubDate>
            <atom:updated>2023-09-15T09:29:03.100Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How I approached Text to SQL without Machine Learning]]></title>
            <link>https://medium.com/@tusharsadana/how-i-approached-text-to-sql-without-machine-learning-3849255d89a?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/3849255d89a</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Tue, 22 Sep 2020 17:45:03 GMT</pubDate>
            <atom:updated>2020-09-25T22:29:50.822Z</atom:updated>
            <content:encoded><![CDATA[<p>Working as a Data Scientist is full of real-life problems, and solving them with Machine Learning is the natural first approach we think of. But is it really necessary to use Machine Learning, every time? To rely on Machine Learning for every problem statement or for matter every answer, is that always the right way?</p><h3>I beg to differ!</h3><p>We do not need to use Machine Learning everywhere and for everything!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/0*fgRGZg5RV3_gzO42.png" /></figure><p>We cannot afford even a slightest of error in an SQL Query and that is quite obvious. A slightest of mistake, syntactically or logically, can range errors from the query not working to fetching irrelevant/wrong data.</p><h4>Avoiding Over Engineering</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*3FHR_xhYJltckc8jhHZEKQ.png" /></figure><p><strong><em>Understanding what our users need.</em></strong></p><p>A platform from where they can generate a SQL Query by giving basic requirements of data. It is not required to make it ultra-sophisticated and add English to SQL. The English language is what is spoken by humans, with multiple contexts in a single sentence. Do we know from which context the user wants the SQL Query, or in what format the context would be beneficial for creating the right query? How will we train users to use the English to SQL?</p><p>These all were just a way to make the product complex and reduce its usability. The purpose was to enable teams working in the Commerce side to generate a query and discard the dependency they generally have on the technical team of the organization.</p><h3>The Approach</h3><p><strong>Data Structures.</strong> Yes, the subject most of us loved in our college days, or probably hate. We all have struggled our way through these and masters the art of googling :P</p><p>The implementation was divided into 4 basic layers. These layers were — <em>Schema, Graph, Helpers, and Queries</em>.</p><p>The Schema layer was to define and let the program know how tables are created in SQL, defining basic usage of Primary Keys, Foreign Keys, Attributes (Columns), and all other metadata about a table including the tables it can be joined to (foreign keys). A basic schema of the queue was also added to use it around the implementation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a672ae08beba6290de4f682cb40080b5/href">https://medium.com/media/a672ae08beba6290de4f682cb40080b5/href</a></iframe><p>The Graph layer works hand in hand with the schema layer. The graph layer is responsible for creating all the tables that exist in your current database. Database Schema was exported from MySQL and a parser was created to create tables. The table&#39;s schema was used to create n tables as in the database. Now, each table was an object Class Table, and each object was a node of the graph.</p><p>We now had “n” nodes. The task was to connect the graph. These relationships were created based on Foreign Keys, Unique Keys, or Primary Keys. The alter table commands were used to identify where the keys were added and they were connected successfully.</p><p>The basic steps were:</p><ol><li>Creating a node that is a table object.</li><li>Adding Keys to the object (obviously the relevant ones).</li><li>Creating a relationship between all the nodes. Logic is in the Github link in the last!</li></ol><p>We were all set to go! Now, I can create queries. There was a minor problem though. Whenever we had to create a “join query”, I had to go through the graph, find the path from one table to end table using any way pathfinding algorithm (Djikstra’s) and then join the tables. It was costly, not always right since, the shortest path is not what I need every time, since, the data drives the table we choose.</p><p>After being stuck for a while, I chose to go for one more Data Structures, Hash Maps! Yes, the one we always used to skip for our exams was now coming handy in real life.</p><p>A double join hash was created. (This is a made term lol). Implementing a BFS — Breadth-First Search algorithm to find all the relationships between the tables and hashing all the possible joins in the table. These are run through to create top to bottom and left to right possible joins. I was able to find about 5.4k unique joins. The has looked something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd1daafe17ba8eb28d5da0e944bb7cd3/href">https://medium.com/media/fd1daafe17ba8eb28d5da0e944bb7cd3/href</a></iframe><p>It is easily seen, the name of tables is in the key separated by “:” and the value contains the two attribute names on which the JOIN will be applied. Cool right!</p><p>Now, this Join Hash was passed through another custom algorithm. This Algorithm Contained startTable:EndTable in the key and the full path like startTable:MidTable1:MidTable2:…:EndTable in the value. Complexity from O(|E|+|V|log|V|) was reduced to O(1). The joining paths can now be extracted from a key:value pair.</p><p>The Helper layer was just used to define “business logic” functions and resolve other business-related queries. It also gave the syntactically correct Where/Joins/Group By/Order By conditions according to the data required given from the Query layer.</p><p>Pass different data context using the format (Table Name, Attribute Name, Type) which is provided from a drop-down UI in the front, they don’t need to remember the type!</p><pre>sampleSelection = [(&#39;students&#39;, &#39;id&#39;, &#39;int(11)&#39;, None), (&#39;students&#39;, &#39;user_id&#39;, &#39;int(11)&#39;, None), (&#39;students&#39;, &#39;first_name&#39;, &#39;varchar(256)&#39;, None), (&#39;users&#39;, &#39;email&#39;, &#39;varchar(1000)&#39;, &#39;students&#39;)]</pre><pre>sampleCondition = [[&quot;profiles&quot;, (&quot;name&quot;, &quot;varchar&quot;), (&quot;like&quot;, &quot;data&quot;),  &#39;jobs&#39;], &quot;AND&quot;, [&quot;students&quot;, (&quot;last_updated&quot;, &quot;timestamp&quot;), (&quot;greaterThan&quot;, &quot;date&quot;), None]]</pre><p>These conditions and selection were taken from the dropdown UI (another post content). The queries were generated like these</p><pre>SELECT students.id, students.user_id, students.first_name FROM students JOIN jobs_profiles ON jobs.id = jobs_profiles.job_id JOIN profiles ON jobs_profiles.profile_id = profiles.id WHERE students.created_at LIKE &quot;abc&quot; OR students.last_updated &gt; &quot;date&quot;</pre><p>This was expected to solve more than 45% of the queries my organization writes in a month. I think that was quite a good start! Find the code here:</p><p><a href="https://bitbucket.org/tusharsadana/texttosql/src/master/">https://bitbucket.org/tusharsadana/texttosql/src/master/</a></p><p>Let me know in the comments how you liked the idea, the approach, and your suggestions! If you enjoyed the posts, I’d love some appreciation, clap, and share it among your friends!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3849255d89a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Boilerplate in TypeScript With Node Package Manager, MongoDB, Express, Node, &…]]></title>
            <link>https://medium.com/swlh/how-to-create-a-boilerplate-in-typescript-with-node-package-manager-mongodb-express-node-dfc1f1e504f6?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfc1f1e504f6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Tue, 21 Apr 2020 01:44:02 GMT</pubDate>
            <atom:updated>2020-04-23T19:29:19.242Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Create a Boilerplate in TypeScript With Node Package Manager, MongoDB, Express, Node, and Redis</h3><h4>Set yourself up a fresh new back-end app with all of these technologies</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lxDFyWOez_9H8hPo" /><figcaption>Photo by <a href="https://unsplash.com/@shanerounce?utm_source=medium&amp;utm_medium=referral">Shane Rounce</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>Boilerplate is the base of an application. The codes which are going to be reused are well defined beforehand, and it is a good coding practice to use proper functions, enumerations, and use descriptive coding strategy.</p><p>With this, your basic backend server will be created. The only thing you will need to add will be the logic of your project.</p><p>Some necessary items or criteria a boilerplate must contain or satisfy:</p><ul><li>Good and readable documentation</li><li>Code structure with a deeper abstraction level</li><li>Follows proper coding standards</li><li>Has CLI tool (for rapid prototyping and setup)</li><li>Scalable</li><li>Easy testing tools</li><li>Necessary API modules</li><li>Support for internationalization and localization</li><li>Code splitting</li><li>Server and client code for setup</li><li>Proper navigation and routing structure</li></ul><p>Today, we will learn how to create a boilerplate and set up a base for the back end using TypeScript, Node, and Express. We’ll also configure it for MongoDB with PM2 — Process Manager will be used to make sure the server stays on and there is no failure.</p><p>This tutorial assumes that you have your Redis server and Mongo already set up.</p><p>We will create an app and install all the required packages in one go. I am providing you with the package.json file. Use npm install<em> </em>to install all the packages in one go. You can install them manually too. You might need some of the packages like pm2 to be installed globally. Make sure every package is installed without any error.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f95729b0a26df191e068bc9d47e4b2c/href">https://medium.com/media/9f95729b0a26df191e068bc9d47e4b2c/href</a></iframe><p>The package.json file goes as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c47131b9407bc38f44b16b7e4c9f522/href">https://medium.com/media/2c47131b9407bc38f44b16b7e4c9f522/href</a></iframe><p>Change the scripts as indicated in the package.json file. We will follow this in the tutorial. You can always change it to whatever you are comfortable with.</p><p>Now the first file we will create is ecosystem.config.js<em>. </em>This file is responsible for your configuration of the PM2 library that will handle the server execution, which is in a cluster in the file. Four instances of a server will be created with automatic load balancing between the instances.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2748374146aac4c945fff896048473b5/href">https://medium.com/media/2748374146aac4c945fff896048473b5/href</a></iframe><p>We need a .gitignore<strong><em> </em></strong>file. You can copy it as shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/19a7755bd1110495752cb7ad75d39174/href">https://medium.com/media/19a7755bd1110495752cb7ad75d39174/href</a></iframe><p>It is now very important to set up the file called tsconfig.json.<strong><em> </em></strong>This file defines the usage of TypeScript instead of JavaScript. What exactly happens is this JSON file gives the configuration to convert the TypeScript code to JavaScript ES6 code. Here, we refer to a file called types.ts.<strong><em> </em></strong>We can define the interface for all the requests we want to make to it in the future. We will define that types.ts later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bd7845e912bbf04b285222c8bbf59f7/href">https://medium.com/media/6bd7845e912bbf04b285222c8bbf59f7/href</a></iframe><p>We will make sure our lint does not work on a few of the files, like the distribution build or the public folder. We will create two files (.eslintignore and .eslintrc.yaml)<strong><em> </em></strong>and add the following code to them:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b96e62c881d410333bf384da249d4017/href">https://medium.com/media/b96e62c881d410333bf384da249d4017/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3f7458db51beace0eaaf0ec0371118c/href">https://medium.com/media/c3f7458db51beace0eaaf0ec0371118c/href</a></iframe><p>So, we have created all the required configuration files for our application. All the files above were created at the root of the project folder. It might look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*Vq1KzKnhdyPYK9HdXj7KGg.png" /></figure><p>We will now start creating the basic structure of our source code for the back end and define basic functions to be used again and again. We will also look into many more things to avoid type errors and create manageable code.</p><p>Let us start by creating a folder named src.<strong><em> </em></strong>In this folder, we will create server.ts,<strong><em> </em></strong>our main server file. The use of each instruction is given in the comments above it. We are using a lot of variables in this that have to be defined in a common config file. Let’s do that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fc4407f0e01c67535842311d42220cc2/href">https://medium.com/media/fc4407f0e01c67535842311d42220cc2/href</a></iframe><p>We will create a folder named common<strong><em> </em></strong>beside src<em>.</em><strong><em> </em></strong>This folder will contain three files: config.ts, messages.ts, and response.ts. As the names suggest, we will have all the common configurations in config.ts. We will have all the messages defined in messages.ts, where we can get a string with respect to an error code, a welcome message, task completion, or failure. In response.ts, we have all the HTTP status codes defined with their strings by their side.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/749cbd81e623296db054e75841fec09e/href">https://medium.com/media/749cbd81e623296db054e75841fec09e/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60b23bd182ecac359990816eacf0efa3/href">https://medium.com/media/60b23bd182ecac359990816eacf0efa3/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30c7c8ea85adf4649503fad4b7476034/href">https://medium.com/media/30c7c8ea85adf4649503fad4b7476034/href</a></iframe><p>We have successfully set up the common<strong><em> </em></strong>folder. Now, we can go to our utils<strong><em> </em></strong>folder, where we will define the basic functions to use different services, caching mechanisms, or packages involved all over the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*5NKl4wfoSZyq1QPE08PO7w.png" /></figure><p>We will first set up a logger in the logger.ts file in the utils folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/31a5086fd057f80aeecbe06f062afe51/href">https://medium.com/media/31a5086fd057f80aeecbe06f062afe51/href</a></iframe><p>Now, we will create platform.ts with all the utility functions to check validity, perform encryption-decryption, and other common functions. You can add more functions to it as per your usage.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7eeecf93e1c9cbfb6f752c8074890d3b/href">https://medium.com/media/7eeecf93e1c9cbfb6f752c8074890d3b/href</a></iframe><p>Further, we will set up Redis (the caching library we will be using). For that, we will create redis.ts<strong><em> </em></strong>in the utils folder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/649967884b49487b92e895f48158b2c5/href">https://medium.com/media/649967884b49487b92e895f48158b2c5/href</a></iframe><p>Now we will define routes.ts.<strong><em> </em></strong>This file is created beside server.ts.<strong><em> </em></strong>You need to define your API routes over here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/749a5695407d4c5cdf32cb5a758beaed/href">https://medium.com/media/749a5695407d4c5cdf32cb5a758beaed/href</a></iframe><p>We are in the last part of our boilerplate. Here, we will create the app<strong><em> </em></strong>folder. This folder will contain the basic CRUD operation for Mongo, the models of the Mongo, and you can add your controllers to this folder by creating another folder in it.</p><p>Let’s create a folder in the app<strong><em> </em></strong>folder — namely models.<strong><em> </em></strong>This will contain types.ts<strong><em> </em></strong>and<strong><em> </em></strong>response.ts.<strong><em> </em></strong>Here, response.ts defines the interface of the HTTP response. As mentioned above, types.ts defines the interface of the requests.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42fd67303d1fdbfe40276539ab7bee74/href">https://medium.com/media/42fd67303d1fdbfe40276539ab7bee74/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97f0cebbb908252eb8046a444c6ce63f/href">https://medium.com/media/97f0cebbb908252eb8046a444c6ce63f/href</a></iframe><p>Now we will create the last file of our boilerplate, crud.ts. This will contain all the create operations, find operations, and delete operations defined. Just pass the model in the function with the relevant value and you can work with Mongo without typing the functions again and again. We will create this file in a folder called mongo<strong><em> </em></strong>in the app<strong><em> </em></strong>folder. All of the error-handling is already implemented.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09ac176cfa94b952662806d1ce08f808/href">https://medium.com/media/09ac176cfa94b952662806d1ce08f808/href</a></iframe><p>The directory must look something like this. If you have changed the name of any folder or file, make sure it was changed everywhere it was used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*1iPs5GAnZefCL6tSPz1MQw.png" /></figure><p>Should we try running our server?</p><p>Create a build with npm run-script build<em>. </em>You might get some errors. This is natural because the back end is still not complete and a lot of stuff is yet to be done to create a full-fledged back end.</p><p>Start your server with pm2 start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rd9jIMDBlJsm9wgk8XrBUw.png" /><figcaption>Servers running.</figcaption></figure><p>You can stop your server with pm2 stop all.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rFBeCO4N8hRkEdBueG9JAw.png" /><figcaption>Servers stopped.</figcaption></figure><p>Or you can start the single instance with npm run serve.</p><p>Don&#39;t forget to start your MongoDB instance and Redis server!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfc1f1e504f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-create-a-boilerplate-in-typescript-with-node-package-manager-mongodb-express-node-dfc1f1e504f6">How to Create a Boilerplate in TypeScript With Node Package Manager, MongoDB, Express, Node, &amp;…</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[Software-Defined Networks — What are these and Why to use them]]></title>
            <link>https://medium.com/analytics-vidhya/software-defined-networks-what-are-these-and-why-to-use-them-35f7ba8101e0?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/35f7ba8101e0</guid>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Sun, 15 Dec 2019 17:48:25 GMT</pubDate>
            <atom:updated>2020-04-30T17:15:59.138Z</atom:updated>
            <content:encoded><![CDATA[<h3>Software-Defined Networks — What are these and Why to use them</h3><p>Internet is not owned by anyone but yet multiple companies are working on equipment to make it accessible to everyone in this world. Be it D-Link, TP-Link or Cisco, we have numerous devices manufactured by them including switches, hub, routers, etc.</p><p>This is basically a closed equipment environment, where proprietary software is bundled with the hardware and a vendor-specific interface is provided to the users.</p><p>In this world of rising technology, we have a plethora of protocols, heaps of header formats, a big bunch of boxes and tons of tools. This vendor-specific firmware is usually updated with a delay, and slow protocol standardization takes place as there are very few people to innovate.</p><p>Here comes SDN — Software Defined Network, where it is a concept to provide seamless mobility, server load balancing, dynamic access control, energy-efficient networking, adaptive traffic networking, network visualization, etc.</p><blockquote>SDN works on a simple concept of centralization. SDN is a network architecture in which a centralized controller controls the forwarding behavior of a set of distributed switches.</blockquote><p><em>or it can be explained as</em></p><blockquote>SDN is a conceptual framework in which networks are treated as abstraction and are controlled programmatically with minimum direct touch of individual network components.</blockquote><p>There are basically two planes in networking, Control Plane and Data Plane. Data plane is the plane where the forwarding of the packets takes place to the next hop, without considering or knowing about the full path, it is just sending the packet to the next interface. Control plane refers to all the functions which are helpful in determining which path to use, including routing protocols, spanning tree, etc.</p><p>Traditionally, both of these planes are handled by each network component individually, while, in SDN, the control plane is centralized and used with the help of a controller, and all the network equipment communicates with the controller for all the queries. While the data plane remains there in each individual component.</p><h3>Main Idea behind SDN</h3><ol><li>Best effort packet switching</li><li>Protocol Layering for modularity</li><li>Relationships between layers</li><li>Scalability</li></ol><p><strong>Best effort packet switching</strong></p><p>Packet Switching:</p><p>Dividing data into packets, and then packets travel separately which can enable statistical multiplexing.</p><p>Packet Delivery:</p><p>Packets may be lost, delayed or out of order. Simplifying network design and failure handling to be done. Build timely, ordered packets, reliability delivery on top.</p><p><strong>Protocol Layering for Modularity</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjGgeZ2rCU4O4tWBbx-laA.jpeg" /></figure><p>Each layer depends only on the interface<br>provided by the layer directly below it<br>• Upper layer picks whichever lower layer it needs<br>• Lower layer multiplexes many upper layers<br>• “Up/down” interface<br>• Peer interfaces across the network implement<br>communication protocols</p><p><strong>SDN is not just using IP addresses, why?</strong></p><ol><li>Links can support any network protocol, not just IP.</li><li>Different addresses can have a different kind of link.</li><li>An adapter may move to a new location, thus providing a static IP is not possible, reconfiguration is needed for this scenario.</li><li>The controller must identify the adapter during bootstrap.</li></ol><p><strong>Scalability</strong></p><p>Directories</p><ol><li>Key-value store, where the key is a name, and value is the address. The query takes in names and provides the address in return.</li><li>Caching response, reusing a response for a period of time, better performance and lower overhead.</li><li>Allow entries to change, updating address(es) associated with a name, with the power to validate or expire cached response.</li></ol><p>Directory Design</p><ol><li>Flood the Query, ARP is applied in search of the MAC who has an IP it is searching for. In large networks, it can be delayed and have a latency of up to a second.</li><li>Push data to all the clients (/etc/hosts), all nodes stores a full copy of directories, can check the addresses needed locally, typically very fast. During updates and changes, there can be more than a million updates in large networks.</li><li>Central Directory Server, All data is handled by one main server. It can result in poor performance, when numerous devices ping the central server at the same time, scalability issues and reliability.</li></ol><p><em>What is the solution then?</em></p><p><strong>Distributed Systems</strong></p><ol><li>Hierarchical Directory — DNS (Domain Name System), following hierarchical namespace, distributed directory and queues and enabling decentralized updates to the directory.</li><li>Distributed Hash Table (Peer to Peer), the directory has a hash table with flat names, each node handles a range of hash output and uses a hash to direct query to directory nodes.</li></ol><p><strong>Data Plane</strong></p><p>The functions taking place in the data plane can be described as follows:</p><ol><li>Matching on all (or some) bits of the packets.</li><li>Performing some actions, like forwarding, access control, mapping header files, traffic monitoring, buffering, shaping and scheduling.</li><li>Matching of destination through MAC Address, to get independent of the location i.e. IP Address.</li><li>It can also match on IP Prefix, i.e. IP addresses grouped into common subnets.</li></ol><p><strong>Forwarding Vs Routing</strong></p><p>Forwarding takes place in the plane, while routing occurs in the control plane. Forwarding is directing data to the outgoing link, each individual router/switch uses the forwarding table and forwards the packet to the destination without considering the final destination. In the control plane, ll the computation occurs to determine the path of the packet to follow and the creation of an individual forwarding table in each switch/router.</p><p><strong>Management Plane</strong></p><p>The control plane also contains a part where all the management and optimization takes place, which is referred to as an altogether a different plane, the management plane.</p><p>The basic functionality is to set the weights of all the paths in the network. The controller gets the input of network topology, link capacities, and traffic matrix. The output id the link weights.</p><p>The objective is simple, minimize the maximum utilization of each link and minimize the sum of link congestion.</p><p><strong><em>Transient Routing Disruptions</em></strong></p><ol><li>Change in Topology, where all the link weight needs to change, or node/link failure, it is needed to be recovered.</li><li>Routing convergence, nodes temporarily disagree to forward packets or route due to overloading or overconsumption which might lead to transient loops and black holes in the network.</li></ol><p><strong>Management plane challenges</strong></p><ol><li>Indirect control, the management plane cannot change the paths, it can only alter the weights of the link, which creates a complex optimization problem.</li><li>Uncoordinated control, management plane cannot control which router will get updated first and started acting on the new protocol while the others are still getting updated, creating a sense of losing coordination in the network.</li><li>Interaction with multiple protocols and mechanisms.</li></ol><blockquote><strong>4 D’s of SDN</strong></blockquote><blockquote><em>Decision- </em>Management and Control Logic</blockquote><blockquote><em>Dissemination- </em>Communicating with the router</blockquote><blockquote><em>Discovery- </em>Topology, and traffic monitoring</blockquote><blockquote><em>Data- </em>Packet handling</blockquote><h3>OpenFlow Switch</h3><p>The switch contains three basic components, Ports, OpenFlow Secure Channel, and Flow Table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z2Ho1rdcwKwA9QpKvrg5_Q.jpeg" /><figcaption>Controller and Switch Connection, and inside of a switch</figcaption></figure><p><strong>Ports</strong></p><p>There are three types of ports</p><ol><li>Physical Ports — the hardware interface</li><li>Logical Ports — the logical interface, the port assigned to logical connections</li><li>Reserved Ports — these ports are used for internal packet processing for special functions such as flooding.</li></ol><p><em>Required Ports</em></p><p>ALL — all the ports that can be used as output ports except the input ports or any ports configured not to forward packets.</p><p>CONTROLLER — it is the port in the secure channel that connects the switch to the controller.</p><p>IN_PORT — when a packet is sent back out to the port from where it was received.</p><p>ANY — a port that is not used either as input or output port but can be represented any or all the ports.</p><p><em>Optional Ports</em></p><p>LOCAL — Ingress and Egress of switch’s local networking and management stacks.</p><p>NORMAL — the output port from the Open Flow process to the normal switch process, only present in hybrid switches.</p><p>FLOOD — the port used to flood the packets by normal switching process to either to all egress hardware or set of egress VLAN ports. Only present in hybrid switched and at output ports only.</p><p><em>How does this Open Flow work?</em></p><p>As soon as a packet arrives, the header fields are sent for the matching, once matched the corresponding action is performed and the counters are updated to keep the statistics. The header fields are as follows:</p><p>Ingress Port, Ethernet Source, Ethernet Destination, VLAN ID, VLAN Priority, IP Source, IP Destination, IP Protocol, IP ToS, Source L4 Port, Destination L4 Port. The flow table consists of these header fields, actions, and various counters.</p><p>The flow table entries are updated frequently and old entries are deleted on the basis of timeout. There are two kinds of timeouts, Idle and Hard. Idle timeout is when an entry is deleted if there are no matching packets in the given time, while in hard timeout in any case after this particular time period the entry is deleted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*ljFaIQ6b4NAtJAjEeSwSMA.png" /></figure><p><em>Various Counter field according to the entity</em></p><p><strong>Per Table — </strong>Active Entries, Packet Lookups, Packet Matches</p><p><strong>Per Flow — </strong>Received Packets, Received Bytes, Duration (Secs), Duration (nano sec)</p><p><strong>Per Port — </strong>Received Packets, Transmitted Packets, Received Bytes, Transmitted Bytes, Receive Drops, Transmit Drops, Receive Errors, Transmit Errors, Receive Frame, Alignment Errors, Receive Overrun errors, Receive CRC Errors, Collisions</p><p><strong>Per Queue — </strong>Transmit Packets, Transmit Bytes,Transmit overrun errors</p><p>The further OpenFlow versions bring concepts like table chaining and group tables with IPv6 support and optical fiber support, which is out of the scope of this article, shall be posting another for those.</p><p>Kindly let me know the feedback on the article in the comments below, and let me know if it helped you in any way!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35f7ba8101e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/software-defined-networks-what-are-these-and-why-to-use-them-35f7ba8101e0">Software-Defined Networks — What are these and Why to use them</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Versioning Is Important and How To Do It Properly]]></title>
            <link>https://medium.com/better-programming/why-versioning-is-important-and-how-to-do-it-686ce13b854f?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/686ce13b854f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Tue, 23 Jul 2019 09:33:09 GMT</pubDate>
            <atom:updated>2019-07-24T22:48:46.312Z</atom:updated>
            <content:encoded><![CDATA[<h4>Implement Semantic Versioning so every dependency stays on the same page</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wKqXbOLqISoFSnYNkrwiOA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@christinhumephoto?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Christin Hume</a> on <a href="https://unsplash.com/search/photos/laptop?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>You might be wondering what a number on software, a game, or an application means. Something like 11.2.3 or maybe 10.4.3.2arm64.</p><p>These are the numbers of the version that the application is currently on or the version it belongs to. Furthermore, this is classified into different types for the same version.</p><h3>Reasons for Versioning</h3><p>But why should we version at all? Is it necessary?</p><p>Most likely, as the application grows, the number of dependencies included in the project will grow with it. The more dependencies, the harder it gets to manage things.</p><p>At times, you might find it difficult to upgrade a dependency without breaking contact with others that probably got too tight to upgrade.</p><p>Other times, dependencies are too loose. Some dependencies provide support for the future, more than is required at times. This is typically a dependency hell.</p><p>A simple solution to this is to start versioning properly, with a common set of rules, which helps every dependency stay on the same page as much as possible.</p><p>This is called <a href="https://semver.org/">Semantic Versioning</a>.</p><h3>Semantic Versioning</h3><p>Semantic Versioning has certain rules that must be followed. These rules can be found on the <a href="https://semver.org/">website</a>.</p><p>We consider a version format of X.Y.Z (Major.Minor.Patch).</p><ul><li>Bug fixes not affecting the API increment the patch version.</li><li>Backward-compatible API additions or changes increment the minor version.</li><li>Backward-incompatible API changes increment the major version.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*0hpnAVl61AG3KwFuRIkHhg.png" /></figure><p>You should read the rules so you know when to increment Major.Minor.Patch of the version and when not to.</p><p>But, isn’t it tedious to update the version of your project every time? There must be a several files where it needs to be updated and you need to remember when you did it last.</p><p>That doesn’t sound so interesting. What if I told you you can do it in a better way?</p><p>This where <a href="https://github.com/c4urself/bump2version">bump2version</a> comes in. <a href="https://github.com/c4urself/bump2version">This GitHub resource</a> is probably the best Python library for versioning I’ve found. How hard could it be?</p><pre>pip install --upgrade bump2version</pre><p>Once you are done with the installation, we need to create a bump configuration file so the script works the way we want it to.</p><p>Let’s assume we have a directory project_xyz and there are two other directories in it: Backend and Frontend.</p><p>Let’s assume also, that Backend contains a file setup.py and Frontend contains a file build.sh. Each of these files contains the version of Frontend and Backend. These versions can be different or similar, depending on how you are incrementing (follow the rules).</p><p>We create a file .bumpversion.cfg (note that it is hidden). This file is going to define where and to what the version should be updated.</p><p>We define the file as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb2b301ed6c88c5d6ecdaf071e24867b/href">https://medium.com/media/fb2b301ed6c88c5d6ecdaf071e24867b/href</a></iframe><p>When you want to increment the version of the whole project you can run some commands in the root of project_xyz and it will automatically update all the files.</p><p>As simple as:</p><pre>bump2version major // 0.1.0 --&gt; 1.0.0</pre><pre>bump2version minor // 0.1.0 --&gt; 0.2.0</pre><pre>bump2version patch // 0.1.0 --&gt; 0.1.1</pre><p>Note that all the files mentioned contain a line:</p><pre>version = 0.1.0 //or the version updated</pre><p>But, whenever you want to do this for individual files (you’ve just updated the Backend for example and want to increment only that), you might prefer:</p><pre>bump2version minor Backend/setup.py</pre><p>There is a way to increment with custom versions as well:</p><pre>to go from 0.5.1 directly to 0.6.1:</pre><pre>bump2version --current-version 0.5.1 --new-version 0.6.1 patch Backend/setup.py</pre><p>Also, there is a way to add messages in versioning:</p><pre>bump2version --message &#39;Build {$BUILD_NUMBER}: {new_version}&#39; patch</pre><p>When you make each commit to Git with all this information, that’s what I call one step closer to atomic Git usage.</p><p>I hope you enjoyed this article, thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=686ce13b854f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/why-versioning-is-important-and-how-to-do-it-686ce13b854f">Why Versioning Is Important and How To Do It Properly</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[How To Use Plotly.js With Angular 8]]></title>
            <link>https://medium.com/better-programming/how-to-use-plotly-js-with-angular-8-2cbf74fd29ba?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/2cbf74fd29ba</guid>
            <category><![CDATA[plotly]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[d3js]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Mon, 22 Jul 2019 11:34:02 GMT</pubDate>
            <atom:updated>2019-07-24T21:20:04.037Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XpYWOJufsyLPdqdiq74CFw.png" /><figcaption>This graph is overloaded but smooth.</figcaption></figure><p>I have been working on a project where I’ve needed to use <a href="https://plot.ly/javascript/">Plotly.js</a> with <a href="https://angular.io/">Angular</a> 8 to plot a custom TDMS file.</p><p>Simple methods I found on the internet worked, but there was a custom requirement of plotting a line graph with more than 1 million points. Browsers end up crashing or slowing down.</p><p>After brainstorming and trying a lot of things, I managed to find a way where this was possible with Angular 8. I found documentation for <a href="http://vanilla-js.com/">Vanilla</a> JavaScript and <a href="https://reactjs.org/">React</a> but nothing for Angular.</p><p>There is an <a href="https://github.com/plotly/angular-plotly.js?files=1">angular-plotly.js repo</a>, which is probably the best version of Plotly for Angular but that seems to work for the smaller graphs and is still a little buggy.</p><h3>Getting Started</h3><p>We are going to use the Vanilla JavaScript version of Plotly in Angular to make it work faster and smoother with their WebGL version.</p><p>This tutorial assumes that you have an application on Angular.</p><p>We will first include Plotly.js in our Angular project.</p><p><a href="https://plot.ly/javascript/getting-started/#download">Download their plotly-latest.min.js</a> (1.48.3 was the version when I was writing this tutorial) from the download section. (You can use the CDN but I wanted to keep my application totally internet-independent).</p><p>If you are using the CDN, simply add the script tag in the index.html.</p><p>If you downloaded the file, copy the file to the assets folder.</p><p>Add this line in angular.json in the scripts tag:</p><pre>&quot;scripts&quot;: [</pre><pre>&quot;src/assets/plotly-latest.min.js&quot;</pre><pre>]</pre><p>We have successfully included the library in our project, now we are going to use it.</p><p>Let’s assume we have a component graph where we are going to use this.</p><p>In graph.component.ts:</p><pre>declare var Plotly: <em>any</em>;<br>export class GraphComponent implements OnInit {<br>...<br>...<br>}</pre><p>We create a div where the graph should be plotted in the HTML file, you can add your CSS and HTML tags accordingly. I’ll provide mine in the end which helped me keep my project responsive.</p><p>graph.component.html</p><pre>&lt;div id=&quot;Graph&quot; #Graph&gt;&lt;/div&gt;</pre><p>Going back to the graph.component.ts.</p><p>We use @ViewChild to find the element from the DOM.</p><p>The reasons to use ViewChild instead of document.getElementById are:</p><ol><li>It is <a href="https://www.typescriptlang.org/">TypeScript</a>.</li><li>If the div is not visible (i.e. it may be in some tab which is to be rendered when you go to that tab, or its visibility is hidden for some reason in the application), the document.getElementById will return an error; it will not find it.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c359d5875eb9519352d4aaa40f82cb07/href">https://medium.com/media/c359d5875eb9519352d4aaa40f82cb07/href</a></iframe><p>Now, we get the data. We can get it from any GET request, a file, or whatever source you might have.</p><p>I am going to use a GET request.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dcce5e7978ecd0c31157d0e0b1c018b4/href">https://medium.com/media/dcce5e7978ecd0c31157d0e0b1c018b4/href</a></iframe><p>Next, we need to format the data in a particular way for this graphing library to work:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a80833f97cbdbd33ca74f5116688940/href">https://medium.com/media/4a80833f97cbdbd33ca74f5116688940/href</a></iframe><p>We’ve formatted the data and it is time to define the layout of the plot and finally plot it.</p><p>We use the function, Plotly.newPlot().</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cf3922ddf764cef0611a295633b835fb/href">https://medium.com/media/cf3922ddf764cef0611a295633b835fb/href</a></iframe><p>Now, serve the application and check.</p><h3>Full TypeScript Code</h3><p>The full code for the TypeScript file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d63e548347c3e496eb9b2009c5e7342e/href">https://medium.com/media/d63e548347c3e496eb9b2009c5e7342e/href</a></iframe><h3>CSS Code</h3><p>The CSS I used to keep it responsive — according to screen orientation and center:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c39df21cdc9239df37883ab04ece76fb/href">https://medium.com/media/c39df21cdc9239df37883ab04ece76fb/href</a></iframe><p>I hope this tutorial was as helpful to you as it was for me. I struggled a lot before this!</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2cbf74fd29ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/how-to-use-plotly-js-with-angular-8-2cbf74fd29ba">How To Use Plotly.js With Angular 8</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[Document Distance]]></title>
            <link>https://medium.com/@tusharsadana/document-distance-7094a4cb732b?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7094a4cb732b</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Mon, 17 Jun 2019 12:14:23 GMT</pubDate>
            <atom:updated>2019-06-17T12:14:23.149Z</atom:updated>
            <content:encoded><![CDATA[<p>Let us assume there are 2 documents D1 and D2. We need to compute the distance between them. Here distance shows similarities between these 2 documents.</p><p>Documents are basically taken as a sequence of words, and words are a string of alphanumeric characters. They are similar if they share a lot of words in common.</p><p>For a Document D and word W. D[W] = the number of times W occur in D (it is an integer).</p><p>For Example:</p><p>D1 = “the cat”</p><p>D2 = “the dog”</p><p>Assume D1 and D2 as vectors.</p><p>Here in the graph, D1 and D2 have “the” in common, therefore both vectors meet at “the” axis, but other parts of vectors lie in a different plane.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/0*KXrbEcUVkptMB47I" /></figure><p>We will denote the distance of two documents as d’(D1, D2).</p><p>Then d’(D1, D2) = D1 . D2 (dot product) = sigmaW D1[W] . D2[W].- We call this as score.</p><p>This dot product is scale invariant the score for a large document is larger.</p><p>To solve this problem, we will divide by the length of vectors, that is the angle between both vectors will give the score.</p><p>Score is d’(D1,D2) = D1. D2 / (|D1||D2|) = arc cosd’</p><p>Algorithm to perform the above:</p><ol><li>Split the document into words.</li><li>Compute word frequencies.</li><li>Dot Product.</li></ol><p>The first step is splitting and saving the words when space appears.</p><p>The second step is performed by iterating through the document and add the words in frequency dictionary.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7094a4cb732b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Peak Finding in Data Structures]]></title>
            <link>https://medium.com/@tusharsadana/peak-finding-in-data-structures-4b822c65f7dc?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b822c65f7dc</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Sun, 17 Feb 2019 09:42:57 GMT</pubDate>
            <atom:updated>2019-02-17T09:43:37.932Z</atom:updated>
            <content:encoded><![CDATA[<p>What is the peak?</p><p>In an array, any position is a peak if and only if the adjacent elements are smaller or equal to than that element on the position. If the position is at any end of the array, then the only adjacent element is considered in the condition.</p><p>Notice that in this case, a peak will always exist.</p><p>Now we will try to find a peak in an array with n elements, and we will try to minimize the time taken by the program, with applying different algorithms.</p><p>For a 1-D array:</p><p>Case 1, linear traversing:</p><p>The worst case is to look at each element and compare the adjacent elements.</p><p>Traversing through the array will take a linear time that is the time taken for traversing is in the order of n or O(n). While comparing takes constant time thus the total time taken in this case is O(n) + C times O(n), i.e. O(n){C+1} unit time.</p><p>Case 2, Binary Search method:</p><p>In this case, we will apply the binary search algorithm to find the peak. Let the array be a.</p><p>Steps to be taken:</p><ol><li>Look at the (n-1)/2 position.</li><li>Compare to right and then left. (particularly in sequence).</li><li>If a[(n-1)/2] &lt; a[(n-1)/2 -1]:</li></ol><p>Then proceed in the left half of the array.</p><p>Else if a[(n-1)/2] &lt; a[(n-1)/2 +1]:</p><p>Then proceed in the right half of the array.</p><p>Else a[(n-1)/2] is the peak.</p><p>In this case, the time significantly decreases. Traversing the array with binary search method takes time of order log of n.</p><p>A comparison here also takes constant time. Thus total time taken here is O(log(n)){C+1}.</p><p>Please note, here log is to the base 2, and ln is used as a log to the base e.</p><p>For 2-D array:</p><p>A peak is a position at which the elements to sides all four sides, up — down — left — right are smaller than the element at the position.</p><p>Case 1, Straight forward traversing:</p><p>Traverse the whole 2-D matrix and compare all the elements.</p><p>This will take O(n2){C+1} time.</p><p>Case 2, Greedy Ascent Algorithm:</p><p>In this case, we can start from any point. The greedy ascent algorithm says we compare values in all direction and go to the direction which has a greater number and at the end when all conditions are done, we find the peak.</p><p>If at a point all four directions have smaller than the center value, then it is the peak.</p><p>WORST CASE- we need to traverse large fraction of 2-D matrix, even which is profitable at the end with respect to time taken.</p><p>Time complexity, in this case, is O(mn) where m and n are rows and columns. For square matrix m=n.</p><p>Case 3, Jamming Binary Search Method Algorithm in Above:</p><p>To do so, we will follow the following steps:</p><ol><li>Pick middle Column j=m/2. Find the global maximum on column j at (i,j).</li><li>Compare (i, j-1); (i, j); (i, j+1)</li><li>Pick left columns if (i, j-1) &gt; (i, j) or Pick right columns if (i, j+1) &gt; (i, j).</li><li>Else (i, j) is a peak.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b822c65f7dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How PayTM is earning from our money?]]></title>
            <link>https://medium.com/@tusharsadana/how-paytm-is-earning-from-our-money-36cb115791d4?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/36cb115791d4</guid>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Mon, 10 Dec 2018 14:19:32 GMT</pubDate>
            <atom:updated>2018-12-10T19:53:29.676Z</atom:updated>
            <content:encoded><![CDATA[<p>I am writing this article with the thought, that how money is revolved and from certain techniques and management skills, we can earn crores. This article is based on my knowledge of Economics and Financial Markets and can be proved wrong, but this is just going to give an idea how our money is being used by PayTM to earn a lot of money without even working.</p><p>From the internet, I found that PayTM claims to have <strong>23 crores</strong> registered users in India. Assuming and through a rough idea from my friends, almost each and every person added about ₹200 in their account every month. Now, if we normalize throughout the country, let’s just settle this at ₹500 being added every year by every user.</p><p>Now, how is the money rotated?</p><p>PayTM takes our money and adds the same amount in its wallet as it seems, but all the money goes into one bank account of PayTM. Whenever a transaction takes place from PayTM to PayTM, there is a change in numbers shown in your wallet, and nothing else. The actual money is still in the same account, just it is shown technically in a different way and ownership of that money keeps on changing.</p><p>According to the statistics, 23 crores x 500 = 11,500 crores every year added in their account, but obviously, this money is not theirs. It can be transferred to banks and other financial institutions. Surprisingly, they don’t even try to stop those transfers.</p><p>For one year it is 11,500 crores, in the account. With 6% of interest per annum, we can see, they can have 6% more in their account, amounting to 690 crores. Over the span of some 5 years, we can conclude as follows:</p><p>*All values in crores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*q6-QCensexNNd5CsoeLo2A.png" /></figure><p>At the end of the 5 years, the total amount reaches to 68,716 crores out of which, only 57,499.996 crores belongs to the public. The other 11,216 crores, is the profit they gained from just interests from the bank.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*TyT3rE_wbXEHvq3qkfVTZQ.png" /></figure><p>Whenever a transaction takes place, PayTM simply changes the digital data, in their database, but the money remains in their account only.</p><p>The average per year was decided on the basis of people also taking their money back, thus the total profit can still exceed the existing figures.</p><p>And then they are found, using our PM’s photographs for promotion without seeking permission.</p><p>Revenue, as claimed by PayTM, is 814 crores, officially.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36cb115791d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What follows after Time Travel?]]></title>
            <link>https://medium.com/@tusharsadana/what-follows-after-time-travel-b020dbfda28b?source=rss-3dd267c408f9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b020dbfda28b</guid>
            <category><![CDATA[time-travel]]></category>
            <category><![CDATA[future]]></category>
            <category><![CDATA[conspiracy-theories]]></category>
            <category><![CDATA[curiosity]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Tushar Sadana]]></dc:creator>
            <pubDate>Sun, 02 Dec 2018 16:51:40 GMT</pubDate>
            <atom:updated>2018-12-02T19:46:42.699Z</atom:updated>
            <content:encoded><![CDATA[<p>Time Travel is intriguing. A hot-shot topic, which seems sparkling and bright. But is it that bright? Have we ever tried to see the dark side of it? Maybe yes. This article is totally based on my thinking, without the influence of any Time Travel Theory or conspiracy. The theories you will be reading further are totally based on my physics knowledge and can be proved wrong! It is just what I wanted to share and put my perspective to the table.</p><ol><li>As per the stats today, some of the nations are very powerful, USA, UK, Germany, China, India. We have a slight perception, if Time Machine is ever going to exist, these few nations will be taking care of that. These are one of those nations, where technologies are booming. Soon, in a few hundred years, one of them might grab an opportunity to travel through time. What all that can be used for?</li><li>These nations can easily change their past. Think of WWII, when Germany lost. What if they send a weapon specialist from future to that time, with all components enough to make those people overpower other armies? How the face of Europe would have been today?</li><li>Imagine India using these to fight against East India Company. The stats and face of economic conditions might turn upside down.</li><li>The USA can conquer the world, and can dictate the whole world! Instead of just being a superpower, it can rule on earth.</li></ol><p>How technology will evolve. If Time Travel can get possible, there must be some instances, where people will try to transfer technologies from future to past. This might create a possibility of inventions to shift early in the timeline. The possibility of the invention of the Time Machine can shift, and the machine can be invented before it actually was invented. This can lead to the exponential evolution of technologies in past, and the technology which we are fascinated by today, can get really common in the 1950s or even before.</p><p>How are we going to be affected biologically? This is an out of scope and vague topic. If our cells, tend to change rapidly due to the actions of humans, the reality would cease to exist. We might turn to mutants since our cells have some memory functions in them (DNA — RNA). They get change but their memory is still intact! Which might speed the evolution of living species on the planet and causing damages to their actual functionalities.</p><p>Time Travel seems easy when we think of going to past. What if we travel to the future, we travel to certain possibilities. There are thousands of possibilities of the next action for a single person. As for the whole planet, there might be zillions or number of possibilities. Won’t that be a reason to get lost in the realm, we aren’t aware of?</p><p>Possibilities don’t cease to exist and the ultimate result might be the end of humanity!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b020dbfda28b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>