<?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 Meet Zaveri on Medium]]></title>
        <description><![CDATA[Stories by Meet Zaveri on Medium]]></description>
        <link>https://medium.com/@meetzaveri?source=rss-923c783c1035------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EwFpvO3rMxXlCEvyLDV6IQ.jpeg</url>
            <title>Stories by Meet Zaveri on Medium</title>
            <link>https://medium.com/@meetzaveri?source=rss-923c783c1035------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 06 Jun 2026 04:08:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@meetzaveri/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[A small intro into o11y: Logs, Metrics, and Traces]]></title>
            <link>https://meetzaveri.medium.com/understanding-observability-the-essentials-of-logs-metrics-and-traces-b3089aa02c61?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3089aa02c61</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[trace]]></category>
            <category><![CDATA[metrics]]></category>
            <category><![CDATA[observability]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 15:00:18 GMT</pubDate>
            <atom:updated>2024-10-11T03:35:36.963Z</atom:updated>
            <content:encoded><![CDATA[<p>You might have been familiar with this term “observability” in modern software engineering era. Yes, I said modern because previously observability existed, but it was in different shape/form. The term has become more synonymous to tech world lately (post-covid era I guess).</p><p>Like you, I was also in that shallow waters of what observability means at abstraction level when the people would talk about, especially the DevOps folklore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8U8rShAC0CDuRdFHjIPww.png" /><figcaption>3 pillars of observability</figcaption></figure><p>I am going to share you my experience on <strong>take on observability</strong> and <strong>why you should care about it</strong>.</p><p>3 pillars of observability</p><ul><li>Logs</li><li>Metrics</li><li>Traces</li></ul><p>there are other components, but so far I&#39;ve come across these 3 when I deal with setting up observability for any project/web-app.</p><h3>Logs</h3><p>Logs, that term you would have been familiar as it dates back to decade or two. Essentially, logs are a piece of text data generated in a particular format. These pieces of text contain crucial information about all stuff going in your system. It may be internal system log, database log, HTTP request log or server log.</p><p>Let me show you example of http-log:</p><pre>{<br>  &quot;timestamp&quot;: &quot;2019-05-30T23:40:24.654+0530&quot;,<br>  &quot;level&quot;: &quot;info&quot;,<br>  &quot;type&quot;: &quot;http-log&quot;,<br>  &quot;detail&quot;: {<br>    &quot;request_id&quot;: &quot;072b3617-6653-4fd5-b5ee-580e9d098c3d&quot;,<br>    &quot;operation&quot;: {<br>      // operation details such as error, req payload and other headers<br>    },<br>    &quot;http_info&quot;: {<br>      &quot;status&quot;: 200,<br>      &quot;http_version&quot;: &quot;HTTP/1.1&quot;,<br>      &quot;url&quot;: &quot;/api/send-mail&quot;,<br>      &quot;ip&quot;: &quot;127.0.0.1&quot;,<br>      &quot;method&quot;: &quot;POST&quot;<br>    }<br>  }<br>}</pre><p>These logs are crucial when it comes to troubleshooting any issue within your software. Essentially, you can find error regarding specific request/operation/program and can get to know why it’s failing at certain time.</p><p>For example, <a href="https://docs.datadoghq.com/logs/">DataDog</a> gives you a platform to store your logs and perform certain analyze/search queries on top of it.</p><h3>Metrics</h3><p>You would have seen those type of images (like below) where you can get visual overview of your system be it, request traffic or CPU/memory or any other stats.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3pmTblCOAzqM_bnz47XnMw.png" /></figure><p>Metrics are stored in time-series database. Don’t overthink database here, but the general rule is that data is stored in time-series fashion, where you have complete control over time range and time interval you want to capture data from, and then you can use it to display in visualization tool such as above one, which in this case is <a href="https://grafana.com/">Grafana</a>.</p><p>When I say database, that also means you can query time-series data over a specific period using certain query language against that database. For example, <a href="https://prometheus.io/">Prometheus</a> provides <a href="https://prometheus.io/docs/prometheus/latest/querying/basics/">PromQL query langauge</a> to query time-series data from Prometheus (it stores data in time-series fashion).</p><p>I’ve used Prometheus so far for capturing the time series data exported from certain 3rd party service (be it metrics collector (like MetricBeat or PromTail) or opentelemetry collector like <a href="https://opentelemetry.io/docs/collector/">OTEL collector</a>).</p><h4>Using metrics, …</h4><p>You can find certain patterns in your system to know where it’s behaving abnormal, which results in performance degradation of your product/web-app. Based on that, you can take certain measures which would alleviate the perf issue and help your product to get back to normal state.</p><h3>Traces</h3><p>Suppose you want to find bottleneck of where is high latency coming from your request pipeline, assuming request pipeline has initial point from client and ends at database. With help of trace , you can observe how request was break down (in spans or segments) and where it had spent most of the time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttugDj_Vg1pv5ALCM8Y70w.png" /><figcaption>a simple snapshot of how trace would look like</figcaption></figure><p>These break down into segments is the most fascinating part of trace, where you can get understanding that which of the services/processes were involved in one specific request/operation and in which “order”. Services here could be client HTTP execution, load balancer, API server, database queries and to name a few.</p><h4><strong>Ending note:</strong></h4><p>That’s all, I had to keep it short and crisp. I hope you had a good time reading it.</p><p><strong>Next up</strong> : I am thinking of writing a post for covering the practical aspect of it, like using OpenTelemetry collector, logging stack (like Loki) and viz dashboard (like Grafana) and showing you how the flow of logs/metrics goes from end-to-end.</p><p>Feel free to leave any kind of feedback !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3089aa02c61" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Track or detect number of tabs open for same website in React]]></title>
            <link>https://meetzaveri.medium.com/track-or-detect-number-of-tabs-open-for-same-website-in-react-f03406ae744b?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/f03406ae744b</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Wed, 16 Mar 2022 18:50:52 GMT</pubDate>
            <atom:updated>2024-02-25T12:00:30.378Z</atom:updated>
            <content:encoded><![CDATA[<h3>Track or detect number of tabs open for same website in React/Javascript</h3><p>I had this scenario where I needed to figure out that how many tabs are open of same website(app) in React.js. Since I researched and came to know that there’s no official API for detecting tabs open for the same website, I needed to develop a solution using whatever JS offers from its existing API with React’s useEffect hook.</p><h4>Core idea</h4><p>We will use help of localStorage API. With that we will keep track of tabs open counter.</p><p>Simply to put words as: we increment counter of “tabs open” when some user opens up a new tab or decrement counter of “tabs open” when some user closes tab or browser.</p><h4>Init (increment tabs open counter) setup</h4><p>First, we implement the base setup for counter increment.</p><p>We check that if key( lets say tabsOpen) is available in localStorage or not. If not, then we initialize by supplying value of 1 to it. Otherwise if it&#39;s available, we simply increment its counter</p><pre>const tabsOpen = localStorage.getItem(&#39;tabsOpen&#39;)<br>console.log(&#39;tabsOpen&#39;, tabsOpen)</pre><pre>if (tabsOpen == null) {<br>  localStorage.setItem(&#39;tabsOpen&#39;, 1)<br>} else {<br>  localStorage.setItem(&#39;tabsOpen&#39;, parseInt(tabsOpen) + parseInt(1))<br>}</pre><h4>Using <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onunload">window.onunload</a> for detecting close event of a tab or browser window</h4><p>We use window.onunload method which helps us when a user closes a tab or whole browser window. That means it programmatically captures closing of tab or window.</p><p>This is where we will decrement the tabs open counter.</p><pre>window.onunload = function (e) {<br>  const newTabCount = localStorage.getItem(&#39;tabsOpen&#39;)<br>  if (newTabCount !== null) {<br>    localStorage.setItem(&#39;tabsOpen&#39;, newTabCount - 1)<br>  }<br>}</pre><h4>Demo</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Rw1xjxCQwNwpSSURWh64lw.gif" /></figure><h4>Final Source Code snippet</h4><p>Place this code snippet into your root component (for eg. App.js) .</p><p><strong>NOTE: Please make sure for you to test this code, you should set/delete localStorage key acc. to your values to reset in to preferable value</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/af938917a595f08c53e8e119c3df9343/href">https://medium.com/media/af938917a595f08c53e8e119c3df9343/href</a></iframe><p>Thanks for reading this. I would love your feedback or criticism for this content, which helps me to structure this article even more better.</p><p>Keep hustling</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f03406ae744b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying React Hooks ]]></title>
            <link>https://meetzaveri.medium.com/simplifying-react-hooks-d45557fcfbc3?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/d45557fcfbc3</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[hooks]]></category>
            <category><![CDATA[react-hook]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Fri, 04 Dec 2020 11:16:41 GMT</pubDate>
            <atom:updated>2020-12-05T06:06:33.552Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>focuses on folks who are coming from class components</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ceXIcIxioF_gJTlxKzJyw.png" /><figcaption>Typical overview of what we are going to do in this post</figcaption></figure><p>In this article, I tried my best to make it easier for you to understand what are <a href="https://reactjs.org/docs/hooks-intro.html">react hooks</a>. I have written this for guys coming from traditional class component pattern who want to explore react hooks.</p><p>We’ll cover how to use useState , useEffect() and more techniques to simulate the experience you were having in class component era</p><h3>🎣 Hooks and Class Components</h3><p>Hooks don’t work inside classes and that gives us benefit of using them in functional component.</p><p>But what about <a href="https://reactjs.org/docs/state-and-lifecycle.html"><strong>lifecycles and state</strong></a> which we were leveraging in class components? Well, there is a way for replicating them in form of hooks.</p><blockquote>Hooks are functions that let you “hook into” React state and lifecycle features from function components. Hooks don’t work inside classes, they let you use React without classes — React.js Official Documentation</blockquote><h4>🌟 Let’s talk about managing state: <a href="https://reactjs.org/docs/hooks-reference.html#usestate">useState</a></h4><p><a href="https://reactjs.org/docs/hooks-reference.html#usestate">useState</a> is a hook which helps us manage state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gw-flQ2GPT5fpf_o5zTd-w.jpeg" /></figure><p>You can get a glimpse from this above image as what useState hook offers. So when you call setToggle(true) then toggle value changes from false to true</p><p>If we were to replicate this into<strong> </strong><a href="https://reactjs.org/docs/components-and-props.html#function-and-class-components"><strong>class component</strong></a> then, it would look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*4KZ99vh8XRkO3Sg49zpP8A.png" /></figure><p>Unlike class, we can’t have multiple state properties into one object. We have to always create another set of useState for new state properties.</p><h3>How to use props?</h3><p>As we know, functional components can access props by either passing it directly in function argument (eg: MyComponent(props)) or you can spread them for performance improvements (eg: MyComponent({name,title}))</p><p>So there’s no explicit API or section on how should we use props in react hooks.</p><h3>🔗 APIs, where we should call them ?!</h3><h4>Old Class-ical way</h4><p>Usually we would write network requests(APIs) in `<a href="https://reactjs.org/docs/react-component.html#componentdidmount">componentDidMount</a>` lifecycle which is the preferable one as per react documentation suggests.</p><pre>componentDidMount(){<br> this.props.getData()<br>}</pre><p>But for hooks we have a similar way to do network requests in particular fashion.</p><h4><a href="https://reactjs.org/docs/hooks-reference.html#useeffect">useEffect</a>( )</h4><p>As documentation says, <em>it’s a hook that lets you perform side effects.</em></p><blockquote>Remember that any useEffect( ) hook will be called atleast once at time of render phase regardless of its arguments</blockquote><p>We can call our APIs in <a href="https://reactjs.org/docs/hooks-reference.html#useeffect">useEffect</a>() as following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/217706131a70291166ce3080d5107c10/href">https://medium.com/media/217706131a70291166ce3080d5107c10/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*nH9MYAVvpBMPdbO94N-gcw.jpeg" /></figure><p>So as you can see if we pass empty array []in second argument of the function and it will be executed only once when that component <strong>completes its first render. </strong>This is because there&#39;re no values in array(i.e. second arg) to keep track of whether those values change or not.</p><p>Take a look at this scenario</p><ol><li>useEffect with <strong>no args</strong>: This means function passed in useEffect(fn)will always trigger when there’s re-render of the component</li><li>useEffect with <strong>empty arg</strong>: This means function passed in useEffect(fn,[name]will trigger atleast once and after that it will trigger whenever the value supplied in argument( []) of useEffect(fn,[name] changes. name here is just a variable containing value which we want to subscribe if it changes or not</li><li>useEffect with one or <strong>more args: </strong>This means function passed in useEffect(fn,[name,title]will trigger atleast once and after that it will trigger whenever the value(s) supplied in argument( []) of useEffect(fn,[name,title] changes</li></ol><p>You can read more about useEffect here — <a href="https://reactjs.org/docs/hooks-effect.html">https://reactjs.org/docs/hooks-effect.html</a></p><h4>Wait, how can I listen to changes for props and state values?</h4><p>The most common approach in class component for this use case was achieved using componentDidUpdate</p><pre>componentDidUpate(prevProps,prevState){<br>  if(prevProps.data !== this.props.data){<br>    // do some action<br>  }<br>}</pre><p>Discuss how useEffect() hook can be used for it</p><p>This can be achieved in hooks by writing your logic in function ofuseEffect and by passing your value on which you want to check if that changed in dependency array[]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*8C3WnBj6LOCtxxZ4FiImvg.jpeg" /></figure><p>Passing our logic into function and list of dependency(s) into dependency array will conclude that whenever any of the dependency(s)’s value changes, then the function will be re-triggered hence our logic will be applied as per old method in class component</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/268a715d4b50d68ff064fbfa4d0d4c61/href">https://medium.com/media/268a715d4b50d68ff064fbfa4d0d4c61/href</a></iframe><blockquote><strong><em>A</em>gain, take note that this useEffect() will always be executed atleast once as I said earlier. This means that if your </strong><strong>props.userInfo hasn’t changed then also your hook will be triggered.</strong></blockquote><p>To overcome this, you could add extra condition in function which differentiates initial state(stale) of props.userInfo</p><h4>When can I know that my component is going to unmount?</h4><p>This can also be achieved via passing [] empty args in useEffect with main function returning another function where we can have unmount logic in it</p><p>You will get clear understanding when you’ll try it with</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95cd48186439f7d73122399fc9995bf5/href">https://medium.com/media/95cd48186439f7d73122399fc9995bf5/href</a></iframe><p>Note there are two things here. 1) the empty braces 2) return function to contain unmounting logic</p><p>This means this useEffect snippet will act like:</p><ol><li>initial logic in function gets executed (as in component just mounted )</li><li>the logic inside return function gets executed when component is unmounted</li></ol><h4>How can I wrap them ?</h4><p>Same way as we did with class components. Yeah literally, we wrap as authWrapper(Dashboard) .</p><h4>📖 Conclusion</h4><p>So folks, these were essential barebones for getting up and running with hooks.</p><p><strong>Please report or suggest me if I have included any misinformation, incorrect logic or lack of proof.</strong></p><p>I will do another post on covering other hooks considering the amount of response I get here.</p><p>Thanks, keep grinding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d45557fcfbc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Vue.js Dashboard Template With ElasticSearch]]></title>
            <link>https://medium.appbase.io/a-vue-js-dashboard-template-with-elasticsearch-6f0f94b522aa?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f0f94b522aa</guid>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[appbase]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Sat, 21 Mar 2020 00:33:40 GMT</pubDate>
            <atom:updated>2020-03-23T08:33:13.082Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Vue.JS Dashboard Template With ElasticSearch</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TvHXttqqN6SLgDZZ.png" /><figcaption><a href="https://charts-dashboard-vue.netlify.com">https://charts-dashboard-vue.netlify.com</a></figcaption></figure><p>Are you looking for a quick boilerplate for your awesome SaaS dashboard project? You’ve come to the right place. We have created a <a href="https://vuejs.org/">Vue</a> dashboard template that is integrated with an <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> backend, <a href="https://vuematerial.io/">vue-material</a> as a design system and <a href="https://vue-chartjs.org/">vue-chartjs</a> for rendering the charts UI widgets. You can change this easily to connect with your own dataset.</p><p>In addition to the pre-built template, we also explain how it works with a code example so that you can create a dashboard UI of your own from the ground up.</p><h3>Not Just Another Dashboard Template</h3><p>While there are many templates available for mock dashboards, they miss out on the most important aspect of using a dashboard. A dashboard exists to enable you to:</p><ol><li>Tailor the data visualizations for your business case,</li><li>Visualize data from a backend source. And what better would be a source be than ElasticSearch — the #1 open-source search and analytics engine that can scale without limiting you down the road,</li><li>Configure the existing UI widgets and be able to add new widgets with ease — ReactiveSearch, our choice of the underlying library here for querying ElasticSearch enables you to do exactly this.</li></ol><blockquote><em>For dashboard, performance matters above all.</em></blockquote><p>With these needs in mind, our data-driven dashboard’s boilerplate comes pre-baked with:</p><ol><li>An <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> backend that’s configurable to your own choice of ES backend and the dataset,</li><li><a href="https://opensource.appbase.io/reactivesearch/">ReactiveSearch</a> — A declarative, props-driven UI library for querying and managing the search state and comes with over 30 UI component presets. This lets you customize both your queries and UIs to render in minutes and comes with extensive documentation,</li><li><a href="https://vue-chartjs.org/">vue-chartjs</a> for rendering the charts UIs. It is a wrapper for Chart.js in Vue. You can easily create reusable chart components. You can either add more charts from these easily or replace them entirely with other charting libraries such as <a href="https://d3js.org/">d3.js</a>, <a href="https://github.com/highcharts/highcharts">highcharts</a> or <a href="https://formidable.com/open-source/victory/">Victory</a>,</li><li><a href="https://auth0.com/">Auth0</a> for the login and authorization functionality. This is easy to extend and tailor for your use-case. You can also choose to replace Auth0 with another OAuth provider such as Firebase,</li></ol><p>You can buy the entire template now for $69 over <a href="http://reactiveapps.io/products/AWuUPhGKOSQtLugWgxfC">here</a>. The template comes with a walkthrough video and you get free updates and support for the next 6 months.</p><p>Try the template live over here- <a href="https://charts-dashboard-vue.netlify.com">https://charts-dashboard-vue.netlify.com</a></p><h3>Who Is This For</h3><p>The need for overall representation of data in a single glance is an essential requirement for all businesses. That’s where a <strong>dashboard</strong> comes into play. The ability for a company to now use real-time graphs and charts that clearly display how key aspects of their business is performing — has gone from a convenient ‘nice to have’ to a ‘<strong>must have</strong>’.</p><p>A dashboard can be used to:</p><ul><li>Enable your business team to visualize the important business metrics in a single glance,</li><li>Share performance and ROI reports with your clients,</li><li>Empower your end-users to visualize metrics relevant to them,</li><li>A collating of existing dashboards into a unifying dashboard.</li></ul><p>There are dashboard builder tools such as <a href="https://www.elastic.co/kibana">Kibana</a> and <a href="https://grafana.com/">Grafana</a> which let you create ElasticSearch powered dashboards with no code. We recommend them whenever they fit your use-case. However, they become limiting as soon as you need:</p><ul><li>A chart that’s not available in their walled garden,</li><li>Need to programmatically filter and visualize the data, e.g. filter data for the logged-in user and set access controls on the data that’s visible,</li><li>Need to integrate other JavaScript code within your dashboard, or extend further by calling other backend routes.</li></ul><h3>What’s Inside This Template</h3><p>This template comes with a dataset that sales data of games published over the years. It contains data visualizations powered by <a href="https://vue-chartjs.org/">vue-chartjs</a>. We use <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> for powering the search (aggregations) backend here and the template is using the <a href="https://opensource.appbase.io/reactivesearch/">ReactiveSearch</a> library to fetch the hits and then render the charts using recharts.</p><p><strong>Tools and libraries we have used in this app:</strong></p><ul><li><a href="https://auth0.com/"><strong>Auth0</strong></a> for Authentication</li><li><a href="https://vuematerial.io/"><strong>vue-material</strong></a> is used for the design system</li><li><a href="https://appbase.io/"><strong>Appbase.io</strong></a> for hosting ElasticSearch</li><li><a href="https://opensource.appbase.io/reactivesearch/"><strong>ReactiveSearch</strong></a> for querying ElasticSearch with a props-driven interface</li><li><a href="https://vue-chartjs.org/"><strong>vue-chartjs</strong></a> for visualizing data via charts UIs</li></ul><h3>Authentication (<a href="https://auth0.com/">Auth0</a>)</h3><p>In this app, we have used Auth0’s library to integrate the authentication flow. It also supports password-less authentication using social login such as Google.</p><p><a href="https://auth0.com/">Auth0</a> supports industry standards such as SAML, OpenID Connect, JSON Web Token, OAuth 2.0, OAuth 1.0a, WS­-Federation, and OpenID. Also, Auth0’s widget(UI) gives you a fully customizable, enterprise-ready login/registration box with just a few lines of JavaScript. You can learn more about it over here — <a href="https://auth0.com/why-auth0/">https://auth0.com/why-auth0/</a>.</p><p><strong>Note:</strong> In the template’s source code, you’ll have to replace existing Auth0 credentials with your ones. AUTH0_CLIENT and AUTH0_DOMAIN are the variables responsible for passing credential values to Auth0 API.</p><h3>Design System (<a href="https://vuematerial.io/">vue-material</a>)</h3><p>The core design system that we have used in this app is vue-material. It follows Material-UI (<a href="https://material-ui.com/">https://material-ui.com/</a>) design specs, so that you can build beautiful apps with Material Design and Vue.js. Dashboard UI’s integral elements like grids, layouts, cards, and various visual elements are built using vue-material.</p><h3>Dataset and Search infrastructure (<a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> + <a href="http://appbase.io/">Appbase.io</a>)</h3><p>This template uses an app that is hosted with <a href="http://appbase.io/">appbase.io</a> — An ElasticSearch hosting provider. We recommend using <a href="http://appbase.io">appbase.io</a> for your own dataset as well as it comes with a free tier, but you can also use any other ElasticSearch hosting provider.</p><h3><a href="https://opensource.appbase.io/reactivesearch">ReactiveSearch</a></h3><p>We have used ReactiveSearch for querying ElasticSearch using declarative props. It comes with a rich API for customizing the queries and comes with over 30 UI component presets.</p><h3>Data Visualization (<a href="https://vue-chartjs.org/">vue-chartjs</a>)</h3><p>We have used vue-chartjs which is wrapper for <a href="https://www.chartjs.org/">chartjs</a> library. You can easily create reusable chart components</p><h3>Screenshots</h3><figure><img alt="https://cdn-images-1.medium.com/max/800/0*VCKx3MbXTHjzhGAK.png" src="https://cdn-images-1.medium.com/proxy/0*VCKx3MbXTHjzhGAK.png" /></figure><p>Landing page for unauthorized user</p><figure><img alt="https://cdn-images-1.medium.com/max/800/0*0D31yMczxSuBJEwH.jpg" src="https://cdn-images-1.medium.com/proxy/0*0D31yMczxSuBJEwH.jpg" /></figure><p>Main dashboard page</p><figure><img alt="https://cdn-images-1.medium.com/max/800/0*dcDgJywquOcNiBr5.png" src="https://cdn-images-1.medium.com/proxy/0*dcDgJywquOcNiBr5.png" /></figure><p>Game Platform Page with filters and pagination</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aUFoD7hgiRWoSVvv.png" /></figure><p><strong>Image:</strong> Specific game view page for a specific platform</p><h3>Try It Live</h3><p>You can try it out live over here — <a href="https://charts-dashboard-vue.netlify.com/">https://charts-dashboard-vue.netlify.com</a>.</p><h3>How To Use ElasticSearch With Vue</h3><p>We have used <a href="https://opensource.appbase.io/reactivesearch/">ReactiveSearch</a> — an open-source library to build the data-driven components in this template. It offers a range of highly customizable rich UI components that can connect with any <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> server and provide you with a good default queries for all the typical search use-cases (think e-commerce, aggregators, events).</p><h3>Components Used:</h3><p><strong>ReactiveBase — </strong>All the ReactiveSearch components are wrapped inside a container component — ReactiveBase which glues the ElasticSearch index and the ReactiveSearch components together.</p><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/vue/overview/ReactiveBase/">here</a>.</p><p><strong>DataSearch — </strong>This component creates a search bar UI that allows a user to search for data inside the dashboard.</p><figure><img alt="https://cdn-images-1.medium.com/max/800/0*LhzmNwUXYSvhLM02.png" src="https://cdn-images-1.medium.com/proxy/0*LhzmNwUXYSvhLM02.png" /></figure><p>GlobalSearch (using DataSearch component)</p><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/vue/search/DataSearch/">here</a>.</p><p><strong>MultiList — </strong>This component helps a user filter data by specific fields, e.g. a filter by year.</p><figure><img alt="https://cdn-images-1.medium.com/max/800/1*TfudKsq5KprnGT4tM_NeEQ.jpeg" src="https://cdn-images-1.medium.com/proxy/1*TfudKsq5KprnGT4tM_NeEQ.jpeg" /></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/vue/list/MultiList/">here</a>.</p><p><strong>ReactiveList — </strong>This component is used for rendering the result list view.</p><figure><img alt="https://cdn-images-1.medium.com/max/800/1*fYTHKRmeYRqHfzIqF2q6qw.png" src="https://cdn-images-1.medium.com/proxy/1*fYTHKRmeYRqHfzIqF2q6qw.png" /></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/vue/result/ReactiveList/">here</a>.</p><p><strong>ReactiveComponent — </strong>This component is responsible for connecting custom Vue components to ElasticSearch on top of ReactiveSearch.</p><p>We have used it to embed chart components with ReactiveSearch layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/0*wbLIDcLZfJJhZWle.png" /></figure><p>Donut chart wrapped with ReactiveComponent which remains in sync with data</p><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/vue/advanced/ReactiveComponent/">here</a>.</p><p>If you are more curious about how to use <a href="https://docs.appbase.io/docs/reactivesearch/vue/advanced/ReactiveComponent/"><strong>ReactiveComponent</strong></a> to build custom data-driven components, here’s an example of building a Donut Chart using it:</p><p><a href="https://codesandbox.io/embed/vue-reactivecomponent-example-fd094?fontsize=14&amp;hidenavigation=1&amp;theme=dark">https://codesandbox.io/embed/vue-reactivecomponent-example-fd094?fontsize=14&amp;hidenavigation=1&amp;theme=dark</a></p><h3>Summary</h3><p>If you are finding challenges in building a performant and data-driven dashboard and want to do it less time, then this template app can help you set up with minimum efforts so that you can <strong><em>focus on your core business logic</em></strong>.</p><p>Compatible with your dataset 📦, Plug’n’Play extensible UI components 🔧, blazing fast backend 🚀, instant search infrastructure ⚡️ and interactive data-visualizations 📊, this dashboard template app is perfect starter for your product’s development.</p><p>💻 You can try it live over <a href="https://charts-dashboard.netlify.com/">here</a>.</p><p>❤️ Buy this template from <a href="https://gum.co/EqqLI">here</a> so you can build that awesome dashboard project in no time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f0f94b522aa" width="1" height="1" alt=""><hr><p><a href="https://medium.appbase.io/a-vue-js-dashboard-template-with-elasticsearch-6f0f94b522aa">A Vue.js Dashboard Template With ElasticSearch</a> was originally published in <a href="https://medium.appbase.io">All things #search</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A React Data Grid Template Powered By ElasticSearch]]></title>
            <link>https://medium.appbase.io/a-react-data-grid-template-powered-by-elasticsearch-a-react-data-grid-template-powered-by-10b21609b67b?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/10b21609b67b</guid>
            <category><![CDATA[template]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[datatables]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[datagrid]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Mon, 24 Feb 2020 15:07:11 GMT</pubDate>
            <atom:updated>2021-01-23T13:03:14.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><a href="https://youthful-shockley-cfbba8.netlify.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FE2ztAFUeJqd0ooiCVAbBw.gif" /></a><figcaption><strong>Image:</strong> <a href="https://youthful-shockley-cfbba8.netlify.com/">Check out the live demo over here</a></figcaption></figure><p>Are you looking for a reusable boilerplate for your next ▦ data grid project? You’ve come to the right place. We have created a React based data grid template that is powered by an <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> backend. It is searchable, filterable and can render thousands of rows on the frontend thanks to <a href="https://github.com/bvaughn/react-virtualized">react-virtualized</a>.</p><h3>Why Yet Another Data Grid Template</h3><p>We hear you! While there are plenty of data grid libraries and templates available that offer an amazing assortment of frontend functionalities, they often don’t consider the performance impact of rendering everything into the DOM and/or how to connect to a backend that doesn’t become limiting as data, filtering and search needs scale.</p><p>Given that ElasticSearch’s main use-case is providing a blazing fast ⚡️ and scalable search and aggregations backend, we offer a React data grid UI that’s powered using <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> as its backend. The frontend is based on <a href="https://github.com/appbaseio/dejavu">Dejavu’s</a> architecture — one of the most popular data browsers for ElasticSearch (over 1MM+ downloads). You can configure the template to work with your own ElasticSearch index. You can also configure a variety of UI options for searching, filtering, sorting, setting page size, switch b/w using pagination and infinite scrolling as well as setting the column visibility.</p><p>In this post, we also explain how you can build a data grid app from ground up using <a href="https://opensource.appbase.io/reactivesearch/">ReactiveSearch</a>, <a href="https://github.com/bvaughn/react-virtualized">react-virtualized</a>, and <a href="https://appbase.io">ElasticSearch</a>.</p><blockquote>You can buy the data grid template with the source code for $99 over <a href="https://gum.co/LjWwa?wanted=true">here</a>. The template comes with a walkthrough video and you will receive free updates for the next 6 months.</blockquote><p><strong>Template Features:</strong></p><ul><li>Apply the template to your dataset and ElasticSearch index</li><li>Infinite scrolling, pagination, and data grouping with global search</li><li>Sorting and filtering data on a column-by-column basis</li><li>Blazing fast search experience</li><li>Ability to customize columns and rows elements</li></ul><blockquote>You can try out the live demo over <a href="https://youthful-shockley-cfbba8.netlify.com/">here</a>.</blockquote><h3>Who Is This For</h3><p>This template is meant for web developers who are looking for building a scalable data grid that doesn’t become limiting down the road.</p><p>Whether you’re considering building your next dashboard project, or your e-commerce search for end users, data grids provide the most flexible way to slice and dice any structured data.</p><p>While the template is powered by ElasticSearch, you don’t need to have experience with it to be able to configure / make the most of it. Our walkthrough video and use of declarative props make it accessible to developers with no prior experience working with it.</p><p>With this template, you can:</p><ul><li>Render tens of thousands of records of data seamlessly,</li><li>Build a delightful search experience powered by appbase.io/ElasticSearch,</li><li>Extend and customize the UI components,</li><li>Use the built-in features for changing filtering, sorting and pagination options.</li></ul><h3>What’s inside this template?</h3><p>This template uses ReactiveSearch and react-virtualized libraries to render the data grid UI.</p><ol><li><a href="https://opensource.appbase.io/reactivesearch">ReactiveSearch</a> — ReactiveSearch is search UI library for data-driven components. We have used ReactiveSearch for querying <strong>ElasticSearch</strong> using declarative props. It comes with a rich API for customizing the queries and comes with over 30 UI component presets.</li><li><a href="https://github.com/bvaughn/react-virtualized">react-virtualized</a> — For rendering large set of data for grid, we have used react-virtualized library which uses virtual rendering techniques to render data without lagging the interface.</li></ol><p>You can check the walkthrough video below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUoK6ComScHI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUoK6ComScHI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FUoK6ComScHI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cbdf0dfa8c87185d23d73b8b3df75b0/href">https://medium.com/media/1cbdf0dfa8c87185d23d73b8b3df75b0/href</a></iframe><h3>A brief idea of ElasticSearch</h3><p><strong>ElasticSearch</strong> is a <a href="https://en.wikipedia.org/wiki/NoSQL">NoSQL</a> database which can search through large amounts of data in a short time. It performs a <a href="https://en.wikipedia.org/wiki/Full-text_search">full-text search</a> on the data which is stored in the form of documents (like objects) by examining all the words in every document.</p><p>Here’s what the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.html">ElasticSearch docs</a> say:</p><blockquote><em>ElasticSearch is a highly scalable open-source full-text search and analytics engine. It allows you to store, search, and analyze big volumes of data quickly and in near real time.</em></blockquote><p>Even if you’ve never used ElasticSearch before, you should be able to follow along with this post and build your very own ElasticSearch powered search using React and ReactiveSearch.</p><h3>How to use ElasticSearch with React?</h3><p>We will be using <a href="https://github.com/appbaseio/reactivesearch">ReactiveSearch</a> — An open-source UI library for building data-driven components for ElasticSearch. In order to search and filter data with ElasticSearch, you need to use the Query DSL — an imperative ElasticSearch specific query language that takes some getting used to if you haven’t worked with search engines in the past. ReactiveSearch simplifies the entire process by offering declarative props, with the ability to override them by writing the QueryDSL.</p><p>In this template, we have used ReactiveList, SelectedFilters, ReactiveBase, MultiList and DataSearch components from the <a href="https://github.com/appbaseio/reactivesearch">ReactiveSearch</a> library.</p><h3>ReactiveBase</h3><p>All the ReactiveSearch components are wrapped inside a container component — ReactiveBase which glues the <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> index and the ReactiveSearch components together. Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/overview/reactivebase/">here</a>.</p><h3>ReactiveList</h3><p>We’ll be using ReactiveList inside the DataTableWrapper component composed with <a href="https://github.com/bvaughn/react-virtualized">react-virtualized</a>. ReactiveList is responsible for rendering list records of data perform Infinite scrolling or pagination.</p><figure><img alt="https://cdn-images-1.medium.com/max/1600/0*tjWxRo7I0FbsBj5Q.png" src="https://cdn-images-1.medium.com/proxy/0*tjWxRo7I0FbsBj5Q.png" /><figcaption><strong>Image:</strong> ReactiveList with pagination enabled.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wmPsoY-PfSbbMvp4.png" /><figcaption><strong>Image:</strong> ReactiveList with infinite scrolling enabled.</figcaption></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/result/reactivelist/">here</a>.</p><h3>DataSearch</h3><p>This component creates a search bar UI which allows us to search for data inside the Table. It has ability to remain linked with ReactiveList which helps to render search results seamlessly.</p><figure><img alt="https://cdn-images-1.medium.com/max/1600/0*U4vntBdR9R-Sval2.png" src="https://cdn-images-1.medium.com/proxy/0*U4vntBdR9R-Sval2.png" /><figcaption><strong>Image:</strong> Global search (using DataSearch component)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Qg_xXYqVul7ov6M.png" /><figcaption><strong>Image:</strong> Example with search highlighting</figcaption></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/search/datasearch/">here</a>.</p><h3>SelectedFilters</h3><p>SelectedFilters creates a selectable filter UI view displaying the current selected values from other components</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JbqBQM39ePsT-JBK.png" /></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/advanced/selectedfilters/">here</a>.</p><h3>The Need For Virtual Rendering</h3><p>Working with data in React is relatively easy because React has capability to isolate data into its component’s state and its children. The hassle begins when the amount of data you need to render becomes massive.</p><p>For a common data grid, one of the main issues that still persists is to have a smooth rendering of data. To overcome this challenge, we use virtual rendering techniques <strong>which will only render list of data visible on screen</strong> and will fetch more data while user scrolls eventually.</p><h4>How We Use <a href="https://github.com/bvaughn/react-virtualized">react-virtualized</a></h4><p>Here we have used <a href="https://github.com/bvaughn/react-virtualized">react-virtualized</a> to enable displaying large amounts of data without making the browser unresponsive. If you are unfamiliar with it and want to check how react-virtualized works, this <a href="https://blog.logrocket.com/rendering-large-lists-with-react-virtualized-82741907a6b3/">post</a> should help you out.</p><h3>Summary</h3><p>If you are looking to build powerful and flexible React data grid powered by <a href="https://appbase.io">ElasticSearch</a>, this template should be a good starting point for you. <a href="https://github.com/appbaseio/reactivesearch">ReactiveSearch</a> enables querying ElasticSearch declaratively — making it accessible to build powerful search UIs. This also makes it easy to tailor both the queries and UIs as per your use-case.</p><p>Try out the live demo over <a href="https://youthful-shockley-cfbba8.netlify.com/">here</a>.</p><blockquote>You can buy the template for a one time use for $99 from <a href="https://gum.co/LjWwa?wanted=true">here</a>.</blockquote><p>This template is part of the <a href="http://reactiveapps.io/">ReactiveSearch Marketplace</a> which contains a variety of other examples such as:</p><ul><li><a href="https://medium.appbase.io/using-elasticsearch-to-create-a-react-based-dashboard-afe064716f20">A React Dashboard Template With ElasticSearch</a></li><li><a href="https://medium.appbase.io/learn-to-build-an-airbnb-like-full-stack-app-video-course-%EF%B8%8F-b43aba34dd99">Learn To Build An Airbnb Like Full Stack App — Video Course ▶️</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10b21609b67b" width="1" height="1" alt=""><hr><p><a href="https://medium.appbase.io/a-react-data-grid-template-powered-by-elasticsearch-a-react-data-grid-template-powered-by-10b21609b67b">A React Data Grid Template Powered By ElasticSearch</a> was originally published in <a href="https://medium.appbase.io">All things #search</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A React Dashboard Template With ElasticSearch]]></title>
            <link>https://medium.appbase.io/using-elasticsearch-to-create-a-react-based-dashboard-afe064716f20?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/afe064716f20</guid>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[dashboard]]></category>
            <category><![CDATA[template]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Fri, 07 Feb 2020 14:28:35 GMT</pubDate>
            <atom:updated>2022-02-24T19:28:33.574Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rTq1VF-U-PZPwFb7frL72g.png" /><figcaption>Try the template live over here — <a href="https://charts-dashboard.netlify.com/">https://charts-dashboard.netlify.com/</a></figcaption></figure><blockquote>Read our latest post update from Feb, 2022 over here: <a href="https://blog.reactivesearch.io/react-dashboard-template-with-elasticsearch">https://blog.reactivesearch.io/react-dashboard-template-with-elasticsearch</a></blockquote><p>Are you looking for a quick boilerplate for your awesome SaaS dashboard project? You’ve come to the right place. We have created a React dashboard template that is integrated with an <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> backend and uses recharts and apexcharts for rendering the charts UI widgets. You can change this easily to connect with your own dataset.</p><p>In addition to the pre-built template, we also explain how it works with a code example so that you can create a dashboard UI of your own from the ground up.</p><h3><strong>Not Just Another Dashboard Template</strong></h3><p>While there are many templates available for mock dashboards, they miss out on the most important aspect of using a dashboard. A dashboard exists to enable you to:</p><ol><li>Tailor the data visualizations for your business case,</li><li>Visualize data from a backend source. And what better would be a source be than ElasticSearch — the #1 open-source search and analytics engine that can scale without limiting you down the road,</li><li>Configure the existing UI widgets and be able to add new widgets with ease — ReactiveSearch, our choice of the underlying library here for querying ElasticSearch enables you to do exactly this.</li></ol><blockquote>For dashboard, performance matters above all.</blockquote><p>With these needs in mind, our data-driven dashboard’s boilerplate comes pre-baked with:</p><ol><li>An <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> backend that’s configurable to your own choice of ES backend and the dataset,</li><li><a href="https://opensource.appbase.io/reactivesearch/">ReactiveSearch</a> — A declarative, props-driven UI library for querying and managing the search state and comes with over 30 UI component presets. This lets you customize both your queries and UIs to render in minutes and comes with extensive documentation,</li><li><a href="http://recharts.org/">Recharts</a> and <a href="https://apexcharts.com/docs/react-charts/">Apexcharts</a> for rendering the charts UIs. They come with a comprehensive selection of charts. You can either add more charts from these easily or replace them entirely with other charting libraries such as <a href="https://d3js.org/">d3.js</a>, <a href="https://github.com/highcharts/highcharts">highcharts</a> or <a href="https://formidable.com/open-source/victory/">Victory</a>,</li><li><a href="https://auth0.com/">Auth0</a> for the login and authorization functionality. This is easy to extend and tailor for your use-case. You can also choose to replace Auth0 with another OAuth provider such as Firebase,</li><li>A map UI (which is also data-driven) that is rendered using <a href="https://www.react-simple-maps.io/">react-simple-maps</a>. You can also extend this and/or replace it with a <a href="https://developers.google.com/maps/documentation">Google Maps</a> / <a href="https://www.openstreetmap.org/">OpenStreetMap</a> based maps UI.</li></ol><p>You can buy the entire template now for $99 over <a href="https://gum.co/EqqLI">here</a>. The template comes with a walkthrough video and you get free updates and support for the next 6 months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDJm5iUejERAdxp3grLnWg.gif" /><figcaption>Try the template live over here — <a href="https://charts-dashboard.netlify.com/">https://charts-dashboard.netlify.com/</a></figcaption></figure><h3>Who Is This For</h3><p>The need for overall representation of data in a single glance is an essential requirement for all businesses. That’s where a <strong>dashboard</strong> comes into play. The ability for a company to now use realtime graphs and charts that clearly display how key aspects of their business is performing — has gone from a convenient ‘nice to have’ to a ‘<strong>must have</strong>’.</p><p>A dashboard can be used to:</p><ul><li>Enable your business team to visualize the important business metrics in a single glance,</li><li>Share performance and ROI reports with your clients,</li><li>Empower your end-users to visualize metrics relevant to them,</li><li>A collating of existing dashboards into a unifying dashboard.</li></ul><p>There are dashboard builder tools such as <a href="https://www.elastic.co/kibana">Kibana</a> and <a href="https://grafana.com/">Grafana</a> which let you create ElasticSearch powered dashboards with no code. We recommend them whenever they fit your use-case. However, they become limiting as soon as you need:</p><ul><li>A chart that’s not available in their walled garden,</li><li>Need to programmatically filter and visualize the data, e.g. filter data for the logged-in user and set access controls on the data that’s visible,</li><li>Need to integrate other JavaScript code within your dashboard, or extend further by calling other backend routes.</li></ul><h3>What’s Inside This Template</h3><p>This template comes with a dataset that sales data of games published over the years. It contains data visualizations powered by <a href="http://recharts.org/en-US/">recharts</a> and <a href="https://apexcharts.com/docs/react-charts/">apexcharts</a>. We use <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> for powering the search (aggregations) backend here and the template is using the <a href="https://opensource.appbase.io/reactivesearch/">ReactiveSearch</a> library to fetch the hits and then render the charts using recharts.</p><p><strong>Tools and libraries we have used in this app:</strong></p><ul><li><a href="https://auth0.com/"><strong>Auth0</strong></a> for Authentication</li><li><a href="https://material-ui.com/"><strong>Material-UI</strong></a> is used for the design system</li><li><a href="https://appbase.io"><strong>Appbase.io</strong></a> for hosting ElasticSearch</li><li><a href="https://opensource.appbase.io/reactivesearch/"><strong>ReactiveSearch</strong></a> for querying ElasticSearch with a props-driven interface</li><li><a href="https://apexcharts.com/docs/react-charts/"><strong>ApexCharts</strong></a><strong>, </strong><a href="http://recharts.org/"><strong>Recharts</strong></a><strong>, </strong>and<strong> </strong><a href="https://www.react-simple-maps.io/"><strong>react-simple-maps</strong></a><strong> </strong>for visualizing data via charts UIs,</li></ul><h4>Authentication (<a href="https://auth0.com/">Auth0</a>)</h4><p>In this app, we have used Auth0’s library to integrate the authentication flow. It also supports password-less authentication using social login such as Google.</p><p><a href="https://auth0.com/">Auth0</a> supports industry standards such as SAML, OpenID Connect, JSON Web Token, OAuth 2.0, OAuth 1.0a, WS­-Federation, and OpenID. Also, Auth0’s widget(UI) gives you a fully customizable, enterprise-ready login/registration box with just a few lines of JavaScript. You can learn more about it over here — <a href="https://auth0.com/why-auth0/">https://auth0.com/why-auth0/</a>.</p><p><strong>Note:</strong> In the template’s source code, you’ll have to replace existing Auth0 credentials with your ones. AUTH0_CLIENT and AUTH0_DOMAIN are the variables responsible for passing credential values to Auth0 API.</p><h4>Design System (<a href="https://material-ui.com/">Material-UI</a>)</h4><p>The core design system that we have used in this app is Material UI (<a href="https://material-ui.com/">https://material-ui.com/</a>) which provides React components and is used by thousands of developers. Dashboard UI’s integral elements like grids, layouts, cards, and various visual elements are built using Material UI.</p><h4>Dataset and Search infrastructure (<a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> + <a href="http://appbase.io/">Appbase.io</a>)</h4><p>This template uses an app that is hosted with <a href="http://appbase.io/">appbase.io</a> — An ElasticSearch hosting provider. We recommend using appbase.io for your own dataset as well as it comes with a free tier, but you can also use any other ElasticSearch hosting provider.</p><h4><a href="https://opensource.appbase.io/reactivesearch"><strong>ReactiveSearch</strong></a></h4><p>We have used ReactiveSearch for querying ElasticSearch using declarative props. It comes with a rich API for customizing the queries and comes with over 30 UI component presets.</p><h4>Data Visualization (<a href="https://apexcharts.com/docs/react-charts/">Apex Charts</a>, <a href="https://github.com/recharts/recharts">Recharts</a>, <a href="https://www.react-simple-maps.io/">react-simple-maps</a>)</h4><p>We have combined set visualizations containing:</p><ul><li><strong>Charts &amp; Graphs</strong> — We are using <a href="https://apexcharts.com/docs/react-charts/">Apex Charts react.js wrapper</a> for building customizable charts. For introducing more variety, we have used the <a href="https://github.com/recharts/recharts">Recharts</a> library.</li><li><strong>Maps</strong> — We are using <a href="https://www.react-simple-maps.io/">react-simple-maps</a> package for displaying a map based on the sales by geography (see image below).</li></ul><h3>Screenshots</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VCKx3MbXTHjzhGAK.png" /><figcaption>Landing page for unauthorized user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0D31yMczxSuBJEwH.jpg" /><figcaption>Main dashboard page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dcDgJywquOcNiBr5.png" /><figcaption>Game Platform Page with filters and pagination</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lfDDb2u6p70cAQ-l.png" /><figcaption><strong>Image:</strong> Specific game view page for a specific platform</figcaption></figure><h3>Try It Live</h3><p>You can try it out live over here — <a href="https://charts-dashboard.netlify.com/">https://charts-dashboard.netlify.com/</a>.</p><h3>How To Use ElasticSearch With React</h3><p>We have used <a href="https://opensource.appbase.io/reactivesearch/">ReactiveSearch</a> — an open-source library to build the data-driven components in this template. It offers a range of highly customizable rich UI components that can connect with any <a href="https://www.elastic.co/elasticsearch">ElasticSearch</a> server and provide you with a good default queries for all the typical search use-cases (think e-commerce, aggregators, events).</p><h4>Components Used:</h4><p><strong>ReactiveBase — </strong>All the ReactiveSearch components are wrapped inside a container component — ReactiveBase which glues the ElasticSearch index and the ReactiveSearch components together.</p><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/overview/reactivebase/">here</a>.</p><p><strong>DataSearch — </strong>This component creates a search bar UI that allows a user to search for data inside the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LhzmNwUXYSvhLM02.png" /><figcaption>GlobalSearch (using DataSearch component)</figcaption></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/search/datasearch/">here</a>.</p><p><strong>MultiList — </strong>This component helps a user filter data by specific fields, e.g. a filter by year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*TfudKsq5KprnGT4tM_NeEQ.jpeg" /></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/list/multilist/">here</a>.</p><p><strong>ReactiveList — </strong>This component is used for rendering the result list view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYTHKRmeYRqHfzIqF2q6qw.png" /></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/result/reactivelist/">here</a>.</p><p><strong>ReactiveComponent — </strong>This component is responsible for connecting custom react components to ElasticSearch on top of ReactiveSearch.</p><p>We have used it to embed chart components with ReactiveSearch layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*DCAImkEf2VzrR9TX.png" /><figcaption>Donut chart wrapped with ReactiveComponent which remains in sync with data</figcaption></figure><p>Read more about it over <a href="https://docs.appbase.io/docs/reactivesearch/v3/advanced/reactivecomponent/">here</a>.</p><p>If you are more curious about how to use <a href="https://docs.appbase.io/docs/reactivesearch/v3/advanced/reactivecomponent/"><strong>ReactiveComponent</strong></a><strong> </strong>to build custom data-driven components, here’s an example of building a Donut Chart using it:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2Fubthx&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2Fubthx&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2Fubthx%2Fscreenshot.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3d0ea92b68638b0dd52abb8ff0d6b0e/href">https://medium.com/media/d3d0ea92b68638b0dd52abb8ff0d6b0e/href</a></iframe><h3>Summary</h3><p>If you are finding challenges in building performant and data-driven dashboard and want to do it less time, then this template app can help you setup with minimum efforts so that you can <strong><em>concentrate on your core business logic</em></strong> as the foremost priority.</p><p>Compatible with your dataset 📦, Plug’n’Play extensible UI components 🔧, blazing fast backend 🚀, instant search infrastructure ⚡️ and interactive data-visualizations 📊, this dashboard template app is perfect starter for your product’s development.</p><p>💻 You can try it live over <a href="https://charts-dashboard.netlify.com/">here</a>.</p><p>❤️ Buy this template from <a href="https://gum.co/EqqLI">here</a> so you can build that awesome dashboard project in no time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afe064716f20" width="1" height="1" alt=""><hr><p><a href="https://medium.appbase.io/using-elasticsearch-to-create-a-react-based-dashboard-afe064716f20">A React Dashboard Template With ElasticSearch</a> was originally published in <a href="https://medium.appbase.io">All things #search</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An intro to Algorithms: Dynamic Programming]]></title>
            <link>https://medium.com/free-code-camp/an-intro-to-algorithms-dynamic-programming-dd00873362bb?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd00873362bb</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Tue, 30 Apr 2019 15:33:33 GMT</pubDate>
            <atom:updated>2019-05-12T05:05:42.405Z</atom:updated>
            <content:encoded><![CDATA[<h3>An intro to Algorithms (Part II): Dynamic Programming</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8c333d_YNEHG4q3UDb1wTA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/5fNmWej4tAA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Helloquence</a> on <a href="https://unsplash.com/search/photos/math?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Suppose you are doing some calculation using an appropriate series of input. There is some computation done at every instance to derive some result. You don’t know that you had encountered the <strong>same output </strong>when you had supplied the <strong>same input</strong>. So it’s like you are doing re-computation of a result that was previously achieved by specific input for its respective output.</p><p>But what’s the problem here? Thing is that your precious time is wasted. You can easily solve the problem here by keeping records that map previously computed results. Such as using the appropriate data structure. For example, you could store input as key and output as a value (part of mapping).</p><blockquote>Those who cannot remember the past are condemned to repeat it. ~Dynamic Programming</blockquote><p>Now by analyzing the problem, store its input if it’s new (or not in the data structure) with its respective output. Else check that input key and get the resultant output from its value. That way when you do some computation and check if that input existed in that data structure, you can directly get the result. Thus we can relate this approach to dynamic programming techniques.</p><h3>Diving into dynamic programming</h3><p>In a nutshell, we can say that dynamic programming is used primarily for optimizing problems, where we wish to find the “best” way of doing something.</p><p>A certain scenario is like there are re-occurring subproblems which in turn have their own smaller subproblems. Instead of trying to solve those re-appearing subproblems, again and again, dynamic programming suggests solving each of the smaller subproblems only once. Then you record the results in a table from which a solution to the original problem can be obtained.</p><p>For instance, the <a href="http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fib.html">Fibonacci numbers</a> 0,1,1,2,3,5,8,13,… have a simple description where each term is related to the two terms before it. If F(n) is the nth term of this series then we have F(n) = F(n-1) + F(n-2). This is called a <strong>recursive formula</strong> or a <strong>recurrence relation.</strong> It needs earlier terms to have been computed in order to compute a later term.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uspMF7wW9P-UZNqAtJOvHA.jpeg" /></figure><p>The majority of Dynamic Programming problems can be categorized into two types:</p><ol><li><strong>Optimization problems.</strong></li><li><strong>Combinatorial problems.</strong></li></ol><p>The optimization problems expect you to select a feasible solution so that the value of the required function is minimized or maximized. Combinatorial problems expect you to figure out the number of ways to do something or the probability of some event happening.</p><h3>An approach to solve: top-down vs bottom-up</h3><p>There are the following two main different ways to solve the problem:</p><p><strong>Top-down: </strong>You start from the top, solving the problem by breaking it down. If you see that the problem has been solved already, then just return the saved answer. This is referred to as <strong><em>Memoization.</em></strong></p><p><strong>Bottom-up: </strong>You directly start solving the smaller subproblems making your way to the top to derive the final solution of that one big problem. In this process, it is guaranteed that the subproblems are solved before solving the problem. This can be called <strong><em>Tabulation</em></strong> (<strong>table-filling algorithm</strong>).</p><p>In reference to iteration vs recursion, bottom-up uses iteration and the top-down uses recursion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJTOwAAuzHCb-2SqQ2gnvA.jpeg" /><figcaption>The visualization displayed in the image is not correct acc. to theoretical knowledge, but I have displayed in an understandable manner</figcaption></figure><p>Here there is a comparison between a naive approach vs a DP approach. You can see the difference by the time complexity of both.</p><h3>Memoization: Don’t forget</h3><p><a href="http://jeffe.cs.illinois.edu/">Jeff Erickson</a> describes in his notes, for Fibonacci numbers:</p><blockquote>The obvious reason for the recursive algorithm’s lack of speed is that it computes the same Fibonacci numbers over and over and over.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*prFg47rkMxIX1KFDWkEwTg.png" /><figcaption>From Jeff Erickson’s notes CC: <a href="http://jeffe.cs.illinois.edu/">http://jeffe.cs.illinois.edu/</a></figcaption></figure><p>We can speed up our recursive algorithm considerably just by writing down the results of our recursive calls. Then we can look them up again if we need them later.</p><p><strong>Memoization</strong> refers to the technique of caching and reusing previously computed results.</p><p>If you use memoization to solve the problem, you do it by maintaining a map of already solved subproblems (as we earlier talked about the <strong>mapping</strong> of key and value). You do it “<strong>top-down</strong>” in the sense that you solve the “top” problem first (which typically recurses down to solve the sub-problems).</p><p><strong>Pseudocode for memoization</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_B5-yYS_UZIpxN_txYzmcg.jpeg" /></figure><p>So using recursion, we perform this with extra overhead memory (i.e. here lookup) to store results. If there is a value stored in the lookup, we return it directly or we add it to lookup for that specific index.</p><p>Remember that there is a tradeoff of extra overhead with respect to the tabulation method.</p><p>However, if you want more visualizations for memoization, then I suggest looking into <a href="https://www.youtube.com/watch?v=Taa9JDeakyU">this video</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WrWMos8SpYKtHmA20pqOnA.jpeg" /><figcaption>In a top-down manner.</figcaption></figure><h3>Tabulation: Filling up in tabular form</h3><p>But once we see how the array (memoized solution) is filled, we can replace the recursion with a simple loop that intentionally fills the array in order, instead of relying on the complicated recursion to do it for us ‘accidentally’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/323/1*WcsHmUUAUiHwKZFw_v5AAg.png" /><figcaption>From Jeff Erickson’s notes CC: <a href="http://jeffe.cs.illinois.edu/">http://jeffe.cs.illinois.edu/</a></figcaption></figure><p>Tabulation does it in <strong>“bottom-up” </strong>fashion. It’s more straight forward, it does compute all values. It requires less overhead as it does not have to maintain mapping and stores data in tabular form for each value. It may also compute unnecessary values. This can be used if all you want is to compute all values for your problem.</p><p><strong>Pseudocode for tabulation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzFgOdCco9jigp-7HZqeiQ.jpeg" /><figcaption>Pseudocode with Fibonacci tree</figcaption></figure><p>As you can see pseudocode (right side) in an image, it does iteration (i.e. loops over till the end of an array). It simply starts with fib(0),fib(1),fib(2),… So with the tabulation approach, we can eliminate the need for recursion and simply return the result with looping over elements.</p><h3>Looking back in history</h3><p>Richard bellman was the man behind this concept. He came up with this when he was working for RAND Corporation in the mid-1950s. The reason he chose this name “dynamic programming” was to hide the mathematics work he did for this research. He was afraid his bosses would oppose or dislike any kind of mathematical research.</p><p>Okay, so the word ‘programming’ is just a reference to clarify that this was an old-fashioned way of planning or scheduling, typically by filling in a table (in a dynamic manner rather than in a linear way) over the time rather than all at once.</p><h4>Wrapping up</h4><p>That’s it. This is part 2 of the algorithm series I started last year. In my <a href="https://codeburst.io/algorithms-i-searching-and-sorting-algorithms-56497dbaef20">previous post</a>, we discussed about what are searching and sorting algorithms. Apologies that I couldn’t deliver this in a shorter time. But I am willing to make things faster in the coming months.</p><p>Hope you liked it and I’ll be soon looking to add a third one in the series soon. Happy coding!</p><p>Resources:</p><ul><li><a href="https://www.hackerearth.com/practice/algorithms/dynamic-programming">Introduction to Dynamic Programming 1 Tutorials &amp; Notes | Algorithms | HackerEarth</a></li><li><a href="https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/">Community - Competitive Programming - Competitive Programming Tutorials - Dynamic Programming: From Novice to Advanced</a></li></ul><p><a href="https://www.geeksforgeeks.org/overlapping-subproblems-property-in-dynamic-programming-dp-1/">https://www.geeksforgeeks.org/overlapping-subproblems-property-in-dynamic-programming-dp-1/</a></p><p>Special props to Jeff Erickson and his notes for algorithm — <a href="http://jeffe.cs.illinois.edu/">http://jeffe.cs.illinois.edu/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*dc1EidebZ_QD_a9g8Em4rA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd00873362bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/an-intro-to-algorithms-dynamic-programming-dd00873362bb">An intro to Algorithms: Dynamic Programming</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Data Structures: Graphs and its traversal algorithms]]></title>
            <link>https://medium.com/hackernoon/graphs-in-cs-and-its-traversal-algorithms-cfee5533f74e?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfee5533f74e</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[graph]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Tue, 24 Jul 2018 12:31:02 GMT</pubDate>
            <atom:updated>2019-06-19T03:35:13.503Z</atom:updated>
            <content:encoded><![CDATA[<p>The vast majority of algorithms of interest operate on data. Therefore, there are particular ways of organizing data that play a critical role in the design and analysis of algorithms. From that, we can say that data structures are simply ways of organizing data.</p><p>They are either <strong>linear or non-linear</strong>. Arrays and linked lists are examples of linear data structures. On the other hand, graphs and trees are forms of non-linear data structures.</p><ul><li>For example, one common data structure is the <strong>list</strong> or <strong>array</strong>, which is an ordered sequence of values. Here’s a list of numbers: 0, 1, 1, 2, 3, 5, 8, 13. The concept of the list isn’t particular to one language, and it’s also used outside of programming in everyday life — wish lists, shopping lists, and so on.</li></ul><p>Algorithms are recipes for logical execution of the problem. They are not the same as data structures. Algorithms are usually “better” if they work faster or more efficiently (using less time, memory, or both).</p><p>But here in this article, it’s all about <strong>looking into non-linear data structures: graphs</strong></p><h3>Diving into graphs</h3><p>A graph is a system in which there are potentially multiple ways to get from an arbitrary point, A, to another arbitrary point, B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pyq3u9YKdprcKdjpM5GUMw.jpeg" /></figure><p>A graph is normally defined as a pair of sets (V,E). V is a set of arbitrary objects called vertices or nodes, and E is a set of pairs of vertices, which we call edges or (more rarely) arcs. In an undirected graph, the edges are unordered pairs, or just sets of two vertices. I usually write<strong> u v</strong> instead of {u,v} to denote the undirected edge between u and v.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HKikanKBE1Eo5h-PFMHDcQ.jpeg" /></figure><p>In a directed graph, the edges are ordered pairs of vertices. I will use <strong>u → v</strong>instead of (u,v) to denote the directed edge from u to v and vice versa for all edges in this article.</p><p>Graphs can also be undirected or directed, cyclic or acyclic (mostly directed), or weighted.</p><h3>Traversing a graph</h3><p>To visit each node or vertex which is a connected component, tree-based algorithms are used. You can do this easily by iterating through all the vertices of the graph, performing the algorithm on each vertex that is still unvisited when examined.</p><p>Two algorithms are generally used for the traversal of a graph: Depth first search (DFS) and Breadth first search (BFS).</p><h4>Depth first search (DFS) algorithm</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kb_QRcGSw4fIAwQcB5Vo7Q.jpeg" /><figcaption>Visualizing DFS traversal</figcaption></figure><blockquote>Depth-first Search (DFS) is an <a href="https://brilliant.org/wiki/algorithm/">algorithm</a> for searching a <a href="https://brilliant.org/wiki/depth-first-search-dfs/(https://brilliant.org/wiki/graphs/)">graph</a> or <a href="https://brilliant.org/wiki/trees-basic/">tree</a> data structure. The algorithm starts at the root (top) node of a tree and goes as far as it can down a given branch (path), and then backtracks until it finds an unexplored path, and then explores it. The algorithm does this until the entire graph has been explored.</blockquote><blockquote>Many problems in computer science can be thought of in terms of graphs. For example, analyzing networks, mapping routes, scheduling, and finding spanning trees are graph problems. To analyze these problems, graph search algorithms like depth-first search are useful. -<a href="https://brilliant.org/wiki/depth-first-search-dfs/">Source</a></blockquote><p>The simplest pseudo-code would be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j79l9kqIx3aCwWZhbSJS4A.jpeg" /></figure><p>Depth-first search is a common way that many people naturally use when solving problems like mazes.</p><p>First, we select a path in the maze (for the sake of this example, let’s choose a path according to some rule we lay out ahead of time) and we follow it until we hit a dead end or reach the end of the maze. If a given path doesn’t work, we backtrack and take an alternative path from a past junction, and try that path.</p><p>To turn this into a graph traversal algorithm, we basically replace “child” with “neighbor”. But to prevent infinite loops, we only want to visit each vertex once. Just like in BFS, we can use marks to keep track of the vertices that have already been visited, so we don’t visit them again. Also, just like in BFS, we can use this search to build a spanning tree with certain useful properties.</p><pre>dfs(vertex v)<br>    {<br>    visit(v);<br>    for each neighbor w of v<br>        if w is unvisited<br>        {<br>        dfs(w);<br>        add edge vw to tree T<br>        }<br>    }</pre><p><strong>Here’s the Python implementation using recursion:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5e78ec0e2f77dc4d6afe898650131a9/href">https://medium.com/media/c5e78ec0e2f77dc4d6afe898650131a9/href</a></iframe><p>This was a basic overview of how DFS works. If you want to dive deeper, there is some great stuff available all over the internet and also on Medium.</p><h4>Breadth first search (BFS) algorithm</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*xjui2i7kEMqRx9QaIFQhaA.png" /></figure><p>It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a ‘search key’), and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level.</p><p>The only catch here is, unlike trees, graphs may contain cycles, so we may come to the same node again. To avoid processing a node more than once, we use a boolean visited array. For simplicity, it is assumed that all vertices are reachable from the starting vertex.</p><p>What we do in a BFS is a simple step-by-step process:</p><ol><li>Start from a vertex <strong>S</strong>. Let this vertex be at what is called…. “Level 0”.</li><li>Find all the other vertices that are immediately accessible from this starting vertex <strong>S</strong>, that is they are only a single edge away (the adjacent vertices).</li><li>Mark these adjacent vertices to be at “Level 1”.</li><li>You might be coming back to the same vertex due to a loop or a ring in the graph. If this happens, your BFS will take <strong>∞</strong> time. So, you will go only to those vertices who do not have their “Level” set to some value.</li><li>Mark which is the parent vertex of the current vertex you’re at, i.e., the vertex from which you accessed the current vertex. Do this for all the vertices at Level 1.</li><li>Now, find all those vertices that are a single edge away from all the vertices which are at “Level 1”. These new set of vertices will be at “Level 2”.</li><li>Repeat this process until you run out of graph.\</li></ol><p>See this — <a href="https://www.programiz.com/dsa/graph-bfs">https://www.programiz.com/dsa/graph-bfs</a></p><p><strong>Python Implementation Using Queue</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66af2dbaf654f977863493b9a19f32ea/href">https://medium.com/media/66af2dbaf654f977863493b9a19f32ea/href</a></iframe><h4>Directed and Undirected graphs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3At4zXqBkUdGSIUiIFnNhw.jpeg" /></figure><p>An <em>undirected graph</em> is a graph in which edges have no orientation. The edge (<em>x</em>, <em>y</em>) is identical to the edge (<em>y</em>, <em>x</em>). That is, they are not ordered pairs, but unordered pairs — i.e., sets of two vertices {<em>x</em>, <em>y</em>} (or 2-multisets in the case of <a href="https://en.wikipedia.org/wiki/Loop_(graph_theory)">loops</a>). The maximum number of edges in an undirected graph without a loop is <em>n</em>(<em>n</em> − 1)/2.</p><p>For any edge uand v in an undirected graph, we call u a neighbor of v and vice versa. The degree of a node is its number of neighbors. In directed graphs, we have two kinds of neighbors. For any directed edge <strong>u — &gt;v</strong>, we call u a predecessor of v and v a successor of u.</p><h4>Cyclic and Acyclic graphs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CbzKFAE5jNR8xMt1NLC2wA.jpeg" /></figure><p>Among the many properties of graphs, two are important for a great number of applications : connectivity and acyclicity. Both are based on the notion of a path.</p><p>A cyclic graph is a graph containing at least one <a href="http://mathworld.wolfram.com/GraphCycle.html">graph cycle</a>. <strong>Also remember that cyclic graphs cannot be a form of tree because tree’s nodes are only visited once via DFS or BFS(traversal methods).</strong></p><p>An acyclic graph is a graph without cycles (a cycle is a complete circuit). When following the graph from node to node, you will never visit the same node twice.</p><h4>What is Directed Acyclic Graph?</h4><p>A directed acyclic graph is an acyclic graph that has a direction as well as a lack of cycles.</p><blockquote>A tree is a formation of Directed acyclic graph</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*FR_yAV48D0y-xQfS.png" /><figcaption>Source — <a href="http://www.statisticshowto.com/directed-acyclic-graph/">http://www.statisticshowto.com/directed-acyclic-graph/</a></figcaption></figure><p>The parts of the above graph are:</p><ul><li><a href="http://www.statisticshowto.com/integer/"><strong>Integer</strong></a> = the set for the the Vertices.</li><li><strong>Vertices set</strong> = {1,2,3,4,5,6,7}.</li><li><strong>Edge set</strong> = {(1,2), (1,3), (2,4), (2,5), (3,6), (4,7), (5,7), (6,7)}.</li></ul><p>A directed acyclic graph has a <strong>topological ordering</strong>. This means that the nodes are ordered so that the starting node has a lower value than the ending node. A DAG has a unique topological ordering if it has a directed path containing all the nodes; in this case the ordering is the same as the order in which the nodes appear in the path.</p><p>In <a href="http://web.cecs.pdx.edu/~sheard/course/Cs163/Doc/Graphs.html">computer science</a>, DAGs are also called <em>wait-for-graphs</em>. When a DAG is used to detect a deadlock, it illustrates that a resources has to <em>wait for</em> another process to continue.</p><p><strong>How can we detect cycles in a graph?</strong></p><p>As it turns out, the reason that the depth-first search algorithm is particularly good at detecting cycles is because of the fact that it is efficient at finding backward edges. We’ll look in to DFS algorithm later in this article</p><h4>Adjacency matrices and adjacency list representation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vw3a7MIwydb5s4K1hqVJGw.jpeg" /><figcaption>Consider this graph as example for understanding adjacency lists and adjacency matrices</figcaption></figure><p>Carrying out graph algorithms using the representation of graphs by lists of edges, or by adjacency lists, can be cumbersome if there are many edges in the graph. To simplify computation, graphs can be represented using matrices. Two types of matrices commonly used to represent graphs will be presented here. One is based on the adjacency of vertices, and the other is based on incidence of vertices and edges.</p><p>Given an adjacency matrix, we can decide in Θ(1) time whether two vertices are connected by an edge just by looking in the appropriate slot in the matrix. We can also list all the neighbors of a vertex in Θ(V) time by scanning the corresponding row (or column).</p><p><strong>Understanding Adjacency matrix from above given image…</strong></p><p>Let’s understand how adjacency matrix is constructed from above given image. For simplicity I have discussed this only for vertex “a” . Same applies to all vertex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ndj8gAMzeTJCF97G6EL0wg.jpeg" /></figure><p>Due to page limit, I have not included analysis for <strong><em>a → d</em></strong> and <strong><em>a → e.</em></strong> As we can conclude from image that there is an edge from a → d and a → e respectively.</p><p><strong>And what about adjacency list?</strong></p><p>The adjacency list data structure should immediately remind you of hash tables with chaining;the two data structures are identical.</p><p>An adjacency list is an array of linked lists, one list per vertex. Each linked list stores the neighbors of the corresponding vertex.</p><p><strong>For example for </strong><strong>a vertex there are edges leading to neighbors as </strong><strong>b,d and e . So its respective linked list contains vertex that are connected via edge.</strong></p><blockquote>Reminder → For undirected graphs, each edge(u,v) is stored twice, once in u’s neighbor list and once in v’s neighbor list; for directed graphs, each edge is stored only once.</blockquote><h4>Weighted Graphs</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fbGjl-sF7PI3KGfGuMruoA.jpeg" /><figcaption>Weighted graph. Source — <a href="https://cs.stackexchange.com">https://cs.stackexchange.com</a></figcaption></figure><p>A weighted graph (or weighted digraph) is a graph (or di-graph) with numbers assigned to its edges. These numbers are called weights or costs. An interest in such graphs is motivated by numerous real-world applications, such as finding the shortest path between two points in a transportation or communication network or the<strong> </strong><a href="https://en.wikipedia.org/wiki/Travelling_salesman_problem"><strong>traveling salesman problem</strong></a><strong>.</strong></p><h4>Examples of graphs in real life</h4><p>Google Maps — it’s just one big graph! Where <strong>Edges represent streets and vertices represent crossings.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*UjbqqPxNGAfNCb3pZGreEg.png" /></figure><p>Graph theory underlies the Internet. It’s very heavily used in networking code (building routing tables, etc), but it comes up all kinds of places like building an internet search engine, or a social media platform.</p><h4>For diving deep into trees, this article is one of the preferable I chose — <a href="https://medium.freecodecamp.org/all-you-need-to-know-about-tree-data-structures-bceacb85490c">https://medium.freecodecamp.org/all-you-need-to-know-about-tree-data-structures-bceacb85490c</a></h4><h3>Facts that matters the most:</h3><ul><li>All trees are graphs. Not all graphs are trees.</li><li>A tree is a kind of graph, Only if it’s connected. For instance, the graph consisting of the vertices A and B and no edges is not a tree, although it is an acyclic graph.</li><li>A single vertex is also considered a tree (no cycles, vacuously connected). So two unconnected vertices makes a forest of two trees.</li><li>A tree is a special kind of graph where there are never multiple paths, that there is always only one way to get from A to B, for all possible combinations of A and B.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*EI6czOBmzzIl9MctzvPtBA.png" /><figcaption>Shot — <a href="https://dribbble.com/shots/3152667-Astronaut-Glove">https://dribbble.com/shots/3152667-Astronaut-Glove</a></figcaption></figure><p>Resources:</p><ul><li><a href="https://brilliant.org/wiki/depth-first-search-dfs/">Depth-First Search (DFS) | Brilliant Math &amp; Science Wiki</a></li><li><a href="https://www.geeksforgeeks.org/">GeeksforGeeks</a></li><li><a href="https://www.khanacademy.org/computing/computer-science/algorithms/">Algorithms | Computer science | Computing | Khan Academy</a></li><li><a href="https://www.hackerearth.com/practice/algorithms">Linear Search Tutorials &amp; Notes | Algorithms | HackerEarth</a></li></ul><p><a href="http://www.cs.uiuc.edu/~jeffe/teaching/algorithms">http://www.cs.uiuc.edu/~jeffe/teaching/algorithms</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfee5533f74e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/graphs-in-cs-and-its-traversal-algorithms-cfee5533f74e">Exploring Data Structures: Graphs and its traversal algorithms</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An intro to Algorithms: Searching and Sorting algorithms]]></title>
            <link>https://codeburst.io/algorithms-i-searching-and-sorting-algorithms-56497dbaef20?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/56497dbaef20</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Sat, 10 Mar 2018 16:53:53 GMT</pubDate>
            <atom:updated>2019-05-12T05:01:52.501Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the seemingly most-overused words in tech is “algorithm”. From the apps on your phone to the sensors in your wearables and how posts appear in your Facebook News Feed, you’ll be pushed to find a service that isn’t powered by some form of algorithm. I am too fascinated how algorithms made an impact in our day-to-day lives</p><blockquote>An algorithm is a finite sequence of precise instructions for performing a computation or for solving a problem.</blockquote><p>For example, here is an algorithm for singing that annoying song “99 Bottles of Beer on the Wall”, for arbitrary values of 99:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*gAE7vtSiWfw5yAsKWRJ5aQ.png" /><figcaption>© Copyright 2014 Jeff Erickson <a href="http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/">http://www.cs.uiuc.edu/~jeffe/teaching/algorithms/</a></figcaption></figure><p>As Donald Knuth wrote in <a href="https://en.wikipedia.org/wiki/The_Art_of_Computer_Programming">The Art of Computer Programming</a>– which could be described as the encyclopedia of algorithms and data structures– it’s a confusing word that looks like someone mashed up logarithm and arithmetic.</p><h4>Properties of Algorithms</h4><ol><li><strong>Input</strong> -An algorithm has input values from a specified set.</li><li><strong>Output</strong> -From each set of input values an algorithm produces output values from a specified set. The output values are the solution to the problem.</li><li><strong>Definiteness</strong> -The steps of an algorithm must be defined precisely.</li><li><strong>Correctness </strong>-An algorithm should produce the correct output values for each set of input values.</li><li><strong>Finiteness </strong>-An algorithm should produce the desired output after a finite (but perhaps large) number of steps for any input in the set.</li><li><strong>Effectiveness </strong>-It must be possible to perform each step of an algorithm exactly and in a finite amount of time.</li><li><strong>Generality </strong>-The procedure should be applicable for all problems of the desired form, not just for a particular set of input values</li></ol><p>Now before heading up to main topic, I want to share the basics of analysis of the algorithms including time complexity and space complexity.</p><h3>Time Complexity and Space Complexity in algorithms</h3><p>Always a question arises -</p><blockquote>When does an algorithm provide a satisfactory solution to a problem?</blockquote><ul><li>One measure of efficiency is the time used by a computer to solve a problem using the algorithm, when input values are of a specified size</li><li>second measure is the amount of computer memory required to implement the algorithm when input values are of a specified size</li></ul><p>Questions such as these involve the <strong>computational complexity</strong> of the algorithm. An analysis of the time required to solve a problem of a particular size involves the <strong>time complexity</strong> of the algorithm. An analysis of the computer memory required involves the <strong>space complexity</strong> of the algorithm.</p><p>There are three types of time complexity —<strong> Best, average and worst case</strong>.</p><p>In simple words for an algorithm, if we could perform and get what we want in just one(eg. on first instance) <strong>computational </strong>approach, then that is said as <strong>O(1) i.e. Time complexity here falls into “Best case” category.</strong></p><p>Say for example, same algorithm results into many <strong>iterations/recursions</strong> or say n times it had to perform to get the result, then the example used for this algorithm describes it’s <strong>worst case time complexity.</strong></p><p>Below are some common time complexities with simple definitions. Feel free to check out <a href="https://en.wikipedia.org/wiki/Time_complexity">Wikipedia</a>, though, for more in-depth definitions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*C1uke5kiJvtn93JIQyPjTQ.png" /><figcaption><a href="https://stackoverflow.com/questions/11032015/how-to-find-time-complexity-of-an-algorithm">https://stackoverflow.com/questions/11032015/how-to-find-time-complexity-of-an-algorithm</a></figcaption></figure><p>Simple example with code -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b21136bb2049220fb24f93800f9f82a0/href">https://medium.com/media/b21136bb2049220fb24f93800f9f82a0/href</a></iframe><p>So scenario on time complexity for this above given example would be -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*XKt30YTJGf4yKZ9w6qsIcA.png" /></figure><h4>Asymptotic Notations</h4><p><strong>Asymptotic Notations</strong> are languages that allow us to analyze an algorithm’s running time by identifying its behavior as the input size for the algorithm increases. This is also known as an algorithm’s growth rate.</p><p>The following 3 asymptotic notations are mostly used to represent time complexity of algorithms:</p><h4>Big Oh (O)</h4><p>Big Oh is often used to describe the worst-case of an algorithm by taking the highest order of a polynomial function and ignoring all the constants value since they aren’t too influential for sufficiently large input.</p><h4>Big Omega (Ω)</h4><p>Big Omega is the opposite of Big Oh, if Big Oh was used to describe the upper bound (worst-case) of a asymptotic function, Big Omega is used to describe the lower bound of a asymptotic function. In analysis algorithm, this notation is usually used to describe the complexity of an algorithm in the best-case, which means the algorithm will not be better than its <strong>best-case</strong>.</p><h4>Big Theta (Θ)</h4><p>When an algorithm has a complexity with lower bound = upper bound, say that an algorithm has a complexity O(n log n) and Ω(n log n), it’s actually has the complexity Θ(n log n), which means the running time of that algorithm always falls in n log n in the best-case and worst-case.</p><p>If you want to dive deep into time complexity, then refer <a href="https://medium.com/u/7a59f0bbd98f">Michael Olorunnisola</a> ‘s article:</p><p><a href="https://medium.freecodecamp.org/time-is-complex-but-priceless-f0abd015063c">Algorithms in plain English: time complexity and Big-O notation</a></p><p>or look at <a href="https://medium.com/u/ae4f9cc01a55">Shilpa Jain</a> ‘s article —</p><p><a href="https://codeburst.io/the-ultimate-beginners-guide-to-analysis-of-algorithm-b8d32aa909c5">The Ultimate Beginners Guide To Analysis of Algorithm</a></p><h4>Space Complexity</h4><p><strong>Space complexity</strong> deals with finding out how much (extra)space would be required by the algorithm with change in the input size. For e.g. it considers criteria of a data structure used in algorithm as <strong><em>Array </em></strong>or <strong><em>linked list.</em></strong></p><p><strong>How to calculate space complexity of an algorithm</strong> — <a href="https://www.quora.com/How-do-we-calculate-space-time-complexity-of-an-algorithm">https://www.quora.com/How-do-we-calculate-space-time-complexity-of-an-algorithm</a></p><p>I’ll cover up at least 2 practically used algorithms in each category based on searching and sorting. I had written pseudocode and explanation in my personal notes(images here).</p><h3>Searching Algorithms</h3><p>Search algorithms form an important part of many programs. Some searches involve looking for an entry in a database, such as looking up your record in the IRS database. Other search algorithms trawl through a virtual space, such as those hunting for the best chess moves. Although programmers can choose from numerous search types, they select the algorithm that best matches the size and structure of the database to provide a user-friendly experience.</p><p>The general searching problem can be described as follows: Locate an element x in a list of distinct elements a1,a2,...an or determine that it is not in the list. The solution to this search problem is the location of the term in the list that equals x and is 0 if x is not in the list.</p><h4>Linear Search</h4><p>The linear search is the algorithm of choice for short lists, because it’s simple and requires minimal code to implement. The linear search algorithm looks at the first list item to see whether you are searching for it and, if so, you are finished. If not, it looks at the next item and on through each entry in the list.</p><h4>How does it work ?</h4><p>Linear search is the basic search algorithm used in data structures. It is also called as sequential search. Linear search is used to find a particular element in an array. It is not compulsory to arrange an array in any order (Ascending or Descending) as in the case of binary search.</p><h4>Into Linear Search</h4><p>Given a sample array as shown in figure and value we want to search for is 7, then it’ll traverse in linear way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0SeM4j4ixhVnYtQfVuccHA.jpeg" /><figcaption>P.S. My handwriting could be sometimes unreadable</figcaption></figure><h4>Pseudocode</h4><p>Here is the pseudocode as divided into two images -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iJ-wipeJTGJIr0PVNkZVA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LP4M3ieHZtBqylLaysXf_Q.jpeg" /></figure><p>Linear search is rarely used practically because other search algorithms such as the binary search algorithm and hash tables allow significantly faster searching comparison to Linear search.</p><h4>Time complexity</h4><p>The time complexity of above algorithm is O(n).</p><p>Simple code in python -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdfafe40cf13316167b83de4780b533e/href">https://medium.com/media/fdfafe40cf13316167b83de4780b533e/href</a></iframe><h3>Binary Search</h3><p>Binary Search is one of the most fundamental and useful algorithms in Computer Science. It describes the process of searching for a specific value in an ordered collection.</p><p>Binary search is a popular algorithm for large databases with records ordered by numerical key. Example candidates include the IRS database keyed by social security number and the DMV records keyed by driver’s license numbers. The algorithm starts at the middle of the database — if your target number is greater than the middle number, the search will continue with the upper half of the database. If your target number is smaller than the middle number, the search will continue with the lower half of the database. It keeps repeating this process, cutting the database in half each time until it finds the record. This search is more complicated than the linear search but for large databases it’s much faster than a linear search.</p><blockquote>This algorithm can be used when the list has terms occurring in order of increasing size</blockquote><p>Binary Search is generally composed of 3 main sections:</p><ol><li><strong>Pre-processing</strong> — Sort if collection is unsorted.</li><li><strong>Binary Search</strong> — Using a loop or recursion to divide search space in half after each comparison.</li><li><strong>Post-processing</strong> — Determine viable candidates in the remaining space.</li></ol><h4>How does it work ?</h4><p>In its simplest form, Binary Search operates on a contiguous sequence with a specified left and right index. This is called the Search Space. Binary Search maintains the left, right, and middle indices of the search space and compares the search target or applies the search condition to the middle value of the collection; if the condition is unsatisfied or values unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. If the search ends with an empty half, the condition cannot be fulfilled and target is not found.</p><h4>Into Binary Search</h4><p>Given a sample array, first we find out midpoint and split it out. If <strong>midpoint </strong>is the search value, then it’s game over. So <strong>O(1)</strong> time complexity is achieved.</p><p>But if it’s not the midpoint’s value, then we have to go on an enchanted search for the value in divided halves. Because of this, now we can achieve time complexity in order of log(n) or n i.e. <strong>O(logn) or O(n).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k4JhchbBh1WddXfgn0jeGg.jpeg" /></figure><p>You can see here in above example that 19 was found after so much of divisions of a single array(lists in python).</p><h4>Pseudocode</h4><p>There are two pesudocodes possible for this algorithm. 1. Iterative 2. Recursive.</p><p>You can find difference between iteration and recursion as part of debates in <a href="https://www.reddit.com/r/learnprogramming/comments/2u49q3/recursion_vs_iteration/">reddit </a>or <a href="https://stackoverflow.com/questions/72209/recursion-or-iteration">stackoverflow</a> .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cGLl3G_wXCfQpkIDbwhUKw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BhjUojbBoKSgr1OVk8PB6Q.jpeg" /></figure><h4>Time complexity</h4><p>The time complexity of Binary Search can be written as</p><pre>T(n) = T(n/2) + c</pre><p>Binary search implementation in python -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b1a434544369a8f39f26bb6ed0f662a/href">https://medium.com/media/5b1a434544369a8f39f26bb6ed0f662a/href</a></iframe><h3>Sorting Algorithms</h3><p>Ordering the elements of a list is a problem that occurs in many contexts. For example, to produce a telephone directory it is necessary to alphabetize the names of subscribers. Similarly, producing a directory of songs available for downloading requires that their titles be put in alphabetic order.</p><p>Putting addresses in order in an e-mail mailing list can determine whether there are duplicated addresses. Creating a useful dictionary requires that words be put in alphabetical order. Similarly, generating a parts list requires that we order them according to increasing part number.</p><p>The <em>Art of Computer Programming</em>, <strong>Donald Knuth</strong> devotes close to 400 pages to sorting, covering around 15 different sorting algorithms in depth! More than 100 sorting algorithms have been devised, and it is surprising how often new sorting algorithms are developed.</p><h4>Bubble Sort</h4><p>Bubble sort algorithm starts by comparing the first two elements of an array and swapping if necessary, i.e., if you want to sort the elements of array in ascending order and if the first element is greater than second then, you need to swap the elements but, if the first element is smaller than second, you mustn’t swap the element. Then, again second and third elements are compared and swapped if it is necessary and this process go on until last and second last element is compared and swapped. This completes the first step of bubble sort.</p><p>To carry out the bubble sort, we perform the basic operation, that is, interchanging a larger element with a smaller one following it, starting at the beginning of the list, for a full pass. We iterate this procedure until the sort is complete.</p><p>It is one of the most inefficient <a href="http://www.algorithmist.com/index.php/Sorting">sorting</a> algorithms because of how simple it is. While asymptotically equivalent to the other algorithms, it will require <strong>O(n²) </strong>swaps in the worst-case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4CxOaO4nxzMswVHRdf2m3w.jpeg" /></figure><h4>Pseudocode (Source — Wikipedia)</h4><p>Suppose a is an array size n</p><pre>swapped = true<br>      while swapped<br>        swapped = false<br>        for j from 0 to N - 1<br>           if a[j] &gt; a[j + 1]<br>              swap( a[j], a[j + 1] )<br>              swapped = true</pre><h4>Time Complexity</h4><ul><li><strong>Worst and Average Case Time Complexity: </strong>O(n*n). Worst case occurs when array is reverse sorted.</li><li><strong>Best Case Time Complexity:</strong> O(n). Best case occurs when array is already sorted.</li></ul><h4>Insertion Sort</h4><p><strong>Insertion sort</strong> is a simple <a href="https://en.wikipedia.org/wiki/Sorting_algorithm">sorting algorithm</a> that builds the final <a href="https://en.wikipedia.org/wiki/Sorted_array">sorted array</a> (or list) one item at a time. It is much less efficient on large lists than more advanced algorithms such as <a href="https://en.wikipedia.org/wiki/Quicksort">quicksort</a>, <a href="https://en.wikipedia.org/wiki/Heapsort">heapsort</a>, or <a href="https://en.wikipedia.org/wiki/Merge_sort">merge sort</a>. However, insertion sort provides several advantages:</p><h4>How it works</h4><p>To sort a list with n elements, the insertion sort begins with the second element. The insertion sort compares this second element with the first element and inserts it before the first element if it does not exceed the first element and after the first element if it exceeds the first element. At this point, the first two elements are in the correct order. The third element is then compared with the first element, and if it is larger than the first element, it is compared with the second element; it is inserted into the correct position among the first three elements.</p><h4>Into Insertion Sort</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ycLtyIz3v5w-zjX2i2tbdQ.jpeg" /></figure><h4>Pseudocode</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*wBzXva-Sr8AsASkd9Ivgkw.png" /></figure><p><strong>Time Complexity:</strong> O(n*n)</p><p><strong>Auxiliary Space: </strong>O(1)</p><p><strong>Boundary Cases</strong>: Insertion sort takes maximum time to sort if elements are sorted in reverse order. And it takes minimum time (Order of n) when elements are already sorted.</p><p><strong>Uses:</strong> Insertion sort is used when number of elements is small. It can also be useful when input array is almost sorted, only few elements are misplaced in complete big array.</p><p>Implementation of Insertion Sort in python -</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fdb8ee96d1187844708de830bf3e351a/href">https://medium.com/media/fdb8ee96d1187844708de830bf3e351a/href</a></iframe><h3>Conclusion</h3><p>So, these were some basic algorithms that will provide a glimpse before diving deep into advanced and complex algorithms. As I titled it “I” part, I think I’ll be making part 2 covering more greedy and dynamic algorithms in future.</p><p>Also If I have been missing some topic to cover or maybe fault in my notes please put suggestions in comment.</p><p>Thank you for spending your time to read this article. Keep coding !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*k54o6Y0a6ifDD8qJFBu4Fg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMjd0UHNBlLD02s7wVYV3Q.jpeg" /><figcaption>❤️ for CS</figcaption></figure><p><a href="https://cdn.dribbble.com/users/571755/screenshots/3516921/big-data.jpg">https://cdn.dribbble.com/users/571755/screenshots/3516921/big-data.jpg</a></p><p>Resources :</p><ul><li><a href="http://blog.thefirehoseproject.com/posts/what-is-an-algorithm/">http://blog.thefirehoseproject.com</a></li><li><a href="https://www.flipkart.com/discrete-mathematics-its-applications-combinatorics-graph-theory-7th/p/itmdwxxszhczjrnf">Rosen’s Discrete Mathematics and its application</a></li><li><a href="https://www.geeksforgeeks.org">GeeksForGeeks</a></li><li><a href="https://www.techwalla.com/articles/types-of-search-algorithms">TechWalla</a></li><li><a href="https://blogs.msdn.microsoft.com">blogs.msdn.microsoft.com</a></li></ul><figure><a href="http://bit.ly/codeburst"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3hPOj27LTt0ZPn5TQuhZg.png" /></a></figure><blockquote>✉️ <em>Subscribe to </em>CodeBurst’s<em> once-weekly </em><a href="http://bit.ly/codeburst-email"><strong><em>Email Blast</em></strong></a><strong><em>, </em></strong>🐦 <em>Follow </em>CodeBurst<em> on </em><a href="http://bit.ly/codeburst-twitter"><strong><em>Twitter</em></strong></a><em>, view </em>🗺️ <a href="http://bit.ly/2018-web-dev-roadmap"><strong><em>The 2018 Web Developer Roadmap</em></strong></a><em>, and </em>🕸️ <a href="http://bit.ly/learn-web-dev-codeburst"><strong><em>Learn Full Stack Web Development</em></strong></a><em>.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56497dbaef20" width="1" height="1" alt=""><hr><p><a href="https://codeburst.io/algorithms-i-searching-and-sorting-algorithms-56497dbaef20">An intro to Algorithms: Searching and Sorting algorithms</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[What is boilerplate and why do we use it? Necessity of coding style guide]]></title>
            <link>https://medium.com/free-code-camp/whats-boilerplate-and-why-do-we-use-it-let-s-check-out-the-coding-style-guide-ac2b6c814ee7?source=rss-923c783c1035------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac2b6c814ee7</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[boilerplate]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[freecodecamp]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Meet Zaveri]]></dc:creator>
            <pubDate>Tue, 02 Jan 2018 16:14:41 GMT</pubDate>
            <atom:updated>2024-01-07T13:04:12.355Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*hrjnxp5fCjg2Hxv8IrImcg.png" /></figure><p>In Information Technology, a boilerplate is a unit of writing that can be reused over and over without change. By extension, the idea is sometimes applied to reusable programming, as in “boilerplate code.”</p><p>Legal agreements, including software and hardware terms and conditions, make abundant use of boilerplates.</p><p>For instance, a lawyer may give you a five page contract to sign, but most of the contract is boilerplate — meaning it’s the same for everyone who gets that contract, with only a few lines changed here and there.</p><p>In computer programming, <strong>boilerplate code</strong> or <strong>boilerplate</strong> refers to sections of code that have to be included in many places with little or no alteration. It is often used when referring to languages that are considered <em>verbose</em>, i.e. the programmer must write a lot of code to do minimal jobs.</p><p>For example, in web development, simple boilerplate for HTML would look like this:</p><pre>&lt;!DOCTYPE html&gt;                       <br>&lt;html class=&quot;no-js&quot; lang=&quot;&quot;&gt;                           <br>&lt;head&gt;                               <br>  &lt;meta charset=&quot;utf-8&quot;&gt;                               <br>  &lt;meta http-equiv=&quot;x-ua-compatible&quot; content=&quot;ie=edge&quot;&gt; <br>    <br>    &lt;title&gt;&lt;/title&gt;              <br>                 <br>  &lt;meta name=&quot;description&quot; content=&quot;&quot;&gt;                         <br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial- scale=1, shrink-to-fit=no&quot;&gt;<br> &lt;link rel=&quot;stylesheet&quot; href=&quot;css/main.css&quot;&gt;<br>&lt;/head&gt;   <br>                       <br> &lt;body&gt;            <br>                  <br>   &lt;p&gt;Hello world! This is HTML5 Boilerplate.&lt;/p&gt;          <br>     &lt;script src=&quot;js/vendor/modernizr-{{MODERNIZR_VERSION}}.min.js&gt;<br>     &lt;/script&gt;</pre><pre> &lt;/body&gt;<br>&lt;/html&gt;</pre><p>You can view the whole repository here :</p><p><a href="https://github.com/h5bp/html5-boilerplate">GitHub - h5bp/html5-boilerplate: A professional front-end template for building fast, robust, and adaptable web apps or sites.</a></p><p>In the 1890s, boilerplate was actually cast or stamped in metal ready for the printing press and distributed to newspaper presses and firms around the United States. Until the 1950s, thousands of newspapers received and used this kind of boilerplate from the nation’s largest supplier, the Western Newspaper Union. Some companies also sent out press releases as boilerplate so that they had to be printed as written.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*QQnxLRyGkTqHamqONvrftA.png" /></figure><p>Most professional web developers have created a collection of assets and snippets of code that they reuse on projects to accelerate development. There are some universal or near universal patterns that all websites share in common. Rather than continuously rebuild these, most developers start by copying the code they used for a similar project and then start modifying it.</p><p>Some developers recognize the value of these boilerplate starter templates and take the time to make the boilerplate more generic and share them online for others to use.</p><p>This is not only limited to web development. It is used beyond in AI/ML as there are more growing frameworks and libraries.</p><h4>Necessary characteristics of boilerplate for large projects (production ready)</h4><ul><li>Good and Readable Documentation 📓</li><li>Code structure with a deeper abstraction level</li><li>Follows Proper Coding Standard</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>After all these minimum specs, you should start editing and altering the code in order to build your project.</p><p>There are some Big Tech Companies who even build their own boilerplate. They use it for respective and similar projects throughout time.</p><p>A perfect example for this would be react.js’s boilerplate:</p><p><a href="https://github.com/react-boilerplate/react-boilerplate">GitHub - react-boilerplate/react-boilerplate: :fire: A highly scalable, offline-first foundation with the best developer experience and a focus on performance and best practices.</a></p><h4>Boilerplate for smaller projects(Scaffolding)</h4><p>These type of boilerplates are generally kind of “Starter Kits” or in professional way it is called “Scaffolding”. Their main target users are novice developers or new early adopters.</p><p>It focuses on fast prototyping by creating the elements which are necessary only for new projects. These require less functionality and are not scalable over time and project.</p><p>Their code structure is not much expanded, and doesn’t involve deeper abstraction layer as users only need to build core features. This eliminates the need for extra utilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*lfaRa-3SmkzcN2cuy3MCYw.png" /><figcaption>Code structure</figcaption></figure><p>The simplest example is Facebook’s create-react-app boilerplate:</p><p><a href="https://github.com/facebookincubator/create-react-app">facebook/create-react-app</a></p><h3>What’s the difference between a boilerplate and a template?</h3><p>I read one answer on Quora which seemed most resonating to me. <strong>Boilerplate</strong> is something that you copy and paste and just add to a document. It comes up most often in contracts where language is used and reused, spelling out things like conditions and caveats.</p><p>Writers use <strong>templates as models</strong>, sometimes with negative effects. In broad terms, a template is a model or pattern used to create new objects. In writing, it is a <strong>standardized form of something like a resume</strong> that writers can use to flesh out their own versions.</p><p>Unlike boilerplates, templates are adapted for a particular use. The problem arose for me when students used Word templates for their resumes, and they all ended up looking the same.</p><p>Both templates and boilerplates can make business writing stilted and artificial if used unwisely.</p><h3>Style Guide for writing code</h3><p>Regardless of whether you’re using boilerplate or not, there are some standards followed by companies for writing code . One of them is <strong>Style Guide. </strong>It attempts to explain the basic styles and patterns that are used in various companies or organizations. It’s generally a rule that employees must adopt the coding style guide of their company.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*VHZwgapkhk1bMWHilZa6vw.png" /></figure><p>The Style Guide describes tons of rules for writing code, like indentation of tabs and spaces, naming of variables and functions, writing necessary comments, formatting, source file structures, using proper method of data structures, avoiding hoisting, scoping, control statements and a lot more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*hxP11Dbe9ksYpK5c8_nU3g.png" /></figure><p>Programming styles commonly deal with the visual appearance of source code with the goal of readability. Software has long been available that formats source code automatically, leaving coders to concentrate on naming, logic, and higher techniques.</p><p>As a practical point, using a computer to format source code saves time, and it is possible to then enforce company-wide standards without <a href="https://en.wikipedia.org/wiki/Flaming_(Internet)#Holy_Wars">debates</a>. (Source — Wiki).</p><p>These are some common debates like: <strong>Tabs v Spaces Holy war</strong>, <strong>choosing the perfect Code IDE</strong>, and so on. The interesting thing is that you can get involved in these debates which mostly happen on <a href="https://www.reddit.com/r/programming/comments/2ban9r/the_great_white_space_debate/"><strong>Reddit</strong></a><strong>. </strong>You can also participate in some of the <a href="https://stackoverflow.com/"><strong>stackoverflow</strong></a> Q&amp;A’s.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rjETUMQ62xAZegCSAglE6Q.png" /><figcaption>source — <a href="https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/">https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/</a></figcaption></figure><p>For web developers, the most common style guide for JS is <strong>Airbnb’s javascript style guide. </strong>It’s open source and everyone can contribute.</p><p><a href="https://github.com/airbnb/javascript">GitHub - airbnb/javascript: JavaScript Style Guide</a></p><p>If anyone is in doubt as to why Javascript needs a style guide, then read this issue’s second answer by <a href="https://twitter.com/hshoff">Harrison Shoff</a>, who is programmer at<strong> Airbnb</strong> .</p><p><a href="https://github.com/airbnb/javascript/issues/102">Why does JavaScript need a style guide? · Issue #102 · airbnb/javascript</a></p><p>Here are some style guides for some of today’s more popular languages:</p><p><a href="https://github.com/dotnet/codeformatter"><strong>DotNet Code Formatter</strong></a></p><p><a href="https://github.com/google/google-java-format"><strong>Java: Google-Java-Format</strong></a></p><p><a href="https://standardjs.com"><strong>Javascript Standard Style</strong></a><strong> (different from airbnb’s javascript)</strong></p><p><a href="http://cs.sensiolabs.org"><strong>PHP Coding Standards Fixe</strong>r</a></p><p><a href="https://github.com/google/yapf/"><strong>Python: Google’s YAPF</strong></a></p><p><a href="http://rubocop.readthedocs.io/en/latest/"><strong>Ruby: Rubocop</strong></a></p><h4>More from Boilerplate: Concept for OOP</h4><p>In <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">object-oriented programs</a>, classes are often provided with methods for <a href="https://en.wikipedia.org/wiki/Mutator_method">getting and setting</a> instance variables. The definitions of these methods can frequently be regarded as boilerplate.</p><p>Although the code will vary from one class to another, it is sufficiently stereotypical in structure that it would be better generated automatically than written by hand.</p><p>For example, in the following <a href="https://en.wikipedia.org/wiki/Java_(programming_language)">Java</a> class representing a pet, almost all the code is boilerplate except for the <a href="https://en.wikipedia.org/wiki/Declaration_(computer_science)">declarations</a> of <em>Pet</em>, <em>name</em>, and <em>owner</em>:</p><pre>public class Pet {<br>    private String name;<br>    private Person owner;</pre><pre>public Pet(String name, Person owner) {<br>        this.name = name;<br>        this.owner = owner;<br>    }</pre><pre>public String getName() {<br>        return name;<br>    }</pre><pre>public void setName(String name) {<br>        this.name = name;<br>    }</pre><pre>public Person getOwner() {<br>        return owner;<br>    }</pre><pre>public void setOwner(Person owner) {<br>        this.owner = owner;<br>    }<br>}</pre><p>Boilerplate definition is becoming more global in many other programming languages nowadays. It comes from OOP and hybrid languages that were once procedural but have become OOP. They now have the same goal of repeating the code you build with a model/template/class/object, so they adopt this term. You make a template, and the only things you do for each instance of a template are the individual parameters.</p><p>This part is what we call boilerplate. You simply re-use the code you made a template of, but with different parameters.</p><h4>Boilerplate as an API</h4><p>Since you’re simply re-using the template code with different parameters, this implies that we could build reusable API’s that only need a change of inputs and outputs.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FaAb7hSCtvGw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DaAb7hSCtvGw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FaAb7hSCtvGw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffd7fdf311f62461ccc530e0852861de/href">https://medium.com/media/ffd7fdf311f62461ccc530e0852861de/href</a></iframe><h3>Conclusion</h3><p>“Boilerplate code” is any seemingly repetitive code that shows up again and again in order to get a result that seems like it ought to be much simpler.</p><p>I wrote this article because I was recently instructed by a Team Lead to learn about the many varieties of boilerplate that might be suitable for our project. So I had to go on a search for the perfect boilerplate.</p><p>Any type of feedback will be appreciated! Hustle On!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac2b6c814ee7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/whats-boilerplate-and-why-do-we-use-it-let-s-check-out-the-coding-style-guide-ac2b6c814ee7">What is boilerplate and why do we use it? Necessity of coding style guide</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>