<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tahir Raza</title>
    <description>The latest articles on DEV Community by Tahir Raza (@tahirraza_se).</description>
    <link>https://dev.to/tahirraza_se</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F348474%2Fdc5f03d2-a7b2-4a59-9612-88829d2a6c18.jpg</url>
      <title>DEV Community: Tahir Raza</title>
      <link>https://dev.to/tahirraza_se</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tahirraza_se"/>
    <language>en</language>
    <item>
      <title>Kotlin from Php Eyes | First Look</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Wed, 10 May 2023 07:33:10 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/kotlin-from-php-eyes-first-look-1md3</link>
      <guid>https://dev.to/tahirraza_se/kotlin-from-php-eyes-first-look-1md3</guid>
      <description>&lt;p&gt;As you might have heard about Kotlin, the new famous easily adoptable language for Java engineers. Kotlin was designed to be an alternative to Java with a concise and easy syntax without much of the boilerplate code as one would do in Java. So naturally it is easier for a Java engineers to learn Kotlin as they are already familiar with the ecosystem and all fancy names and building mechanism.&lt;/p&gt;

&lt;p&gt;But for someone like me who has never worked with Java, but do have experience with PHP and Python, how this new language feels and look like?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gradle/Maven buil&lt;/li&gt;
&lt;li&gt;Namespaces vs packages&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Delegates&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Extension Functions&lt;br&gt;
&lt;a href="https://kotlinlang.org/docs/extensions.html#extension-functions"&gt;https://kotlinlang.org/docs/extensions.html#extension-functions&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lambdas&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scope Functions&lt;br&gt;
&lt;a href="https://kotlinlang.org/docs/scope-functions.html#function-selection"&gt;https://kotlinlang.org/docs/scope-functions.html#function-selection&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Data Classes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Equals and HashCode Functoions&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Serialization&lt;br&gt;
A million ways to do something &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>kotlin</category>
    </item>
    <item>
      <title>PHP: FPM | FastCGI | mod_php</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Thu, 10 Nov 2022 07:19:59 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/php-fpm-fastcgi-modphp-4hpa</link>
      <guid>https://dev.to/tahirraza_se/php-fpm-fastcgi-modphp-4hpa</guid>
      <description>&lt;p&gt;PHP, a widely spread scripting language mainly used for websites or more specifically backend web development. You might have heard these terms mentioned in the title of the post but if you are someone like me, then you probably don't fully understand these things.&lt;/p&gt;

&lt;p&gt;So todays post will be more about the definitions, conceptual differences and pros/cons for one over the other.&lt;/p&gt;

&lt;p&gt;Whenever I want to learn something new I follow some simple steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Understand the meaning/definition of the new term&lt;/li&gt;
&lt;li&gt;Learn about the history&lt;/li&gt;
&lt;li&gt;Learn with examples and/or learn with alternatives&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So let's try to follow this approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  PHP
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Meaning/Definition
&lt;/h3&gt;

&lt;p&gt;PHP, originally extracted from Personal Home Page Tools, now stands for PHP: Hypertext Preprocessor.&lt;/p&gt;

&lt;h3&gt;
  
  
  History
&lt;/h3&gt;

&lt;p&gt;Rasmus Lerdorf is the guy who created of PHP and Andi Gutmans and Zeev Suraski are the creators of the Zend Engine.&lt;br&gt;
You can read an in detail &lt;a href="https://en.wikipedia.org/wiki/PHP#History"&gt;historical background on the wiki page&lt;/a&gt; if you like but the interesting fact is PHP's first version was released way back in June 1995. Yes it's that old.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example Usage
&lt;/h3&gt;

&lt;p&gt;PHP executes on the server, while on the hand JavaScript executes on the client.&lt;br&gt;
PHP is mostly used for backend web development but it is also fully capable to make command line applications.&lt;/p&gt;

&lt;p&gt;Now as you know that PHP runs on the server, you may ask what servers? how does a server know how to run PHP? And that's where the mod_php, fastCGI and FPM comes into picture.&lt;/p&gt;

&lt;p&gt;First things first, let's understand a few terms.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mod_php: Module PHP&lt;/li&gt;
&lt;li&gt;CGI: Common Gateway Interface&lt;/li&gt;
&lt;li&gt;FastCGI: Fast Common Gateway Interface
FastCGI is a binary protocol for interfacing interactive programs with a web server. It is a variation on the earlier Common Gateway Interface (CGI).&lt;/li&gt;
&lt;li&gt;FPM: FastCGI Process Manager&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ok so now you at least know the definitions of acronyms.&lt;/p&gt;

&lt;p&gt;Today we will look into two different ways to run PHP on a server and there are two very well known backend servers used to run PHP &lt;a href="https://httpd.apache.org/"&gt;Apache&lt;/a&gt; and &lt;a href="https://www.nginx.com/"&gt;Nginx&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So to run PHP on these servers there are two ways:&lt;br&gt;
You can run PHP as a module in Apache server (mod_php) or you can run PHP as an independent process (PHP FPM) and configure the server to use the process to handle PHP files.&lt;/p&gt;

&lt;p&gt;A simple google search ("php fpm vs mod_php") will give you a lot of good resources on how to configure these two and what are the benefits of one over the other but there are key differences I would like quickly share with you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;PHP FPM is way faster then mod_php&lt;br&gt;
mod_PHP locks out processes and disrupts the performance of a website&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTTP 2 Support&lt;br&gt;
If you want HTTP 2 support you should go with PHP FPM as mod_php does not support it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A more detailed and in my opinion more accurate reading on this is a stackoverflow answer, &lt;a href="https://serverfault.com/a/645765/468540"&gt;please read here if you are interested&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Trees | A beautiful data structure</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Fri, 15 Jul 2022 22:18:54 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/trees-a-beautiful-data-structure-1ag1</link>
      <guid>https://dev.to/tahirraza_se/trees-a-beautiful-data-structure-1ag1</guid>
      <description>&lt;p&gt;During my journey from the forest of data structures I saw a tree and I loved it :D Pardon me for the casual joke.&lt;br&gt;
But yes, today I would like to talk a bit about Tree data structure.&lt;/p&gt;

&lt;p&gt;If you have ever used a social media platform - you have been exposed to a system which heavily used trees data structure. Some people classify it as a hard one to understand but I think it is fascinating and makes our lives easier in a lot of cases.&lt;/p&gt;

&lt;p&gt;The tutorial timeline will look something like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is Tree?&lt;/li&gt;
&lt;li&gt;Why it exist?&lt;/li&gt;
&lt;li&gt;Types of Tree?&lt;/li&gt;
&lt;li&gt;Real world examples&lt;/li&gt;
&lt;li&gt;Implementation&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Tree - What is it?
&lt;/h3&gt;

&lt;p&gt;It is a non-linear hierarchal data structure that consists of nodes and edges. So it is a lot of new words so first let's get out the new terms out of the way.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Non-linear hierarchal: Unlike arrays or linked list this data structure is designed to hold data which is linked in a hierarchal manner. &lt;strong&gt;Hierarchal&lt;/strong&gt; means it is capable of holding data which has a parent child relation within.&lt;/li&gt;
&lt;li&gt;Node: A node is an entity that contains a key or value and pointers to its child nodes.&lt;/li&gt;
&lt;li&gt;Edge: The link between any two nodes is called an edge.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Tree is a data structure, and binary tree is a type of this data structure. Every binary tree is a tree but every tree is not a binary tree.&lt;/p&gt;
&lt;h3&gt;
  
  
  Tree - Why?
&lt;/h3&gt;

&lt;p&gt;In simple words, we needed something to access data in an efficient way. Tree access time is better than linked list.&lt;/p&gt;

&lt;p&gt;Another reason: Trees are really useful when you want to save data which naturally forms a hierarchal relation. Simplest common world example can be a family tree and rather trivial tech example can be one database indexing.&lt;/p&gt;
&lt;h3&gt;
  
  
  Real world examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Database indexing is used using a special kind of tree called  B-Tree or B+ Tree.&lt;/li&gt;
&lt;li&gt;DNS - It also uses a tree data structure.&lt;/li&gt;
&lt;li&gt;In some machine learning algorithm decision tree based learning is used.&lt;/li&gt;
&lt;li&gt;XML parsers use trees.&lt;/li&gt;
&lt;li&gt;Binary search tree, Heaps, Heap Sort, Huffman coding tree, syntax tree are also some of the examples where trees are used.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;Enough verbose, let get straight into the implementation.&lt;br&gt;
As we know, tree is a collection to nodes related to each other with the edges so what does a tree node look like?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's say if we want to create a tree like below. How can we do that?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#     1
#    / \
#   2   3
#  / \
# 4   5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One way would be to do it manually creating root/parent nodes and adding children to it but I would like to share a better way. We can write a function which recursively creates a tree from array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;nodes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above array is the representation of the tree we are talking about and if you notice, if &lt;code&gt;i&lt;/code&gt; is the parent node the left child is &lt;code&gt;2i+1&lt;/code&gt; and the right child is &lt;code&gt;2i+2&lt;/code&gt;. Using this we can easily write the function to create the tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;nodes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;createTree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

    &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;createTree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;createTree&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hmm, now we have created our tree but how can we see it? or more formally speaking, how can we visit all the nodes of our tree?&lt;br&gt;
This is called &lt;strong&gt;traversing&lt;/strong&gt;. If English is not your first language, like me, traversing means "travel across or through." or simply "move back and forth or sideways".&lt;br&gt;
So how can we do that?&lt;br&gt;
Traversing is mainly three types and it depends on the root node.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pre-order&lt;/li&gt;
&lt;li&gt;Post-order&lt;/li&gt;
&lt;li&gt;In-order&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://www.pexels.com/photo/workplace-with-modern-laptop-with-program-code-on-screen-3888151/"&gt;Photo by Rodrigo Santos&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>python</category>
    </item>
    <item>
      <title>Heapify a list into Max Heap</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Fri, 15 Jul 2022 22:16:00 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/heapify-a-list-into-max-heap-5en4</link>
      <guid>https://dev.to/tahirraza_se/heapify-a-list-into-max-heap-5en4</guid>
      <description>&lt;p&gt;If you don't know - Heap is one of the awesome data structures you should learn. Why?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Heap can find min/max in &lt;code&gt;O(1)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Insertion/Deletion can be done in &lt;code&gt;O(logn)&lt;/code&gt; whereas in arrays insertion take &lt;code&gt;O(n)&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;If you learn this data structure, you will be able to grasp heap-sort, priority queue and heapifying an array concept.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are interested to learn more about Heaps, here are some resources to get you started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Heap_(data_structure)"&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=HqPJF2L5h9U"&gt;Simplest video explanation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So how you can convert an array to a Heap.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="nb"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;45&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;getChildren&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pIndex&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;leftIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pIndex&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;rightIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pIndex&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

    &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;leftIndex&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;leftIndex&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rightIndex&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;rightIndex&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;heapify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;getChildren&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;bigChild&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="n"&gt;bigChildIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="n"&gt;bigChildIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

        &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;bigChild&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;bigChildIndex&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bigChild&lt;/span&gt;
            &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;bigChildIndex&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;

            &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bigChildIndex&lt;/span&gt;
            &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;getChildren&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;bigChild&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;bigChildIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;heapify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://www.pexels.com/photo/abstract-business-code-coder-270348/"&gt;Photo by Pixabay&lt;/a&gt;&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>LinkedList | Python | Basics to Advance</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Mon, 27 Jun 2022 11:33:23 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/linkedlist-python-basics-to-advance-1ph1</link>
      <guid>https://dev.to/tahirraza_se/linkedlist-python-basics-to-advance-1ph1</guid>
      <description>&lt;h2&gt;
  
  
  Why we should learn this?
&lt;/h2&gt;

&lt;p&gt;We all know data structures and algorithms are the foundation of being a good software engineer.&lt;/p&gt;

&lt;p&gt;Usually these foundation concepts are considered to be worthy only if you are in university or you are preparing for an interview for a big tech company.&lt;/p&gt;

&lt;p&gt;But I have a different take on this. As an engineer you should be asking yourself this question: "As an engineer should I know X?" and if the answer is yes then please put some time in that topic to be a good engineer in general not because you are trying to score a job.&lt;/p&gt;

&lt;p&gt;So, the questions is, as engineers - you think we should know the most basic but useful data structure called Linked-List?&lt;/p&gt;

&lt;p&gt;I heard a big yes!!&lt;/p&gt;

&lt;p&gt;So let's begin:&lt;/p&gt;

&lt;h3&gt;
  
  
  Definition and Dictionary
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Linked list is a linear data structure.&lt;/li&gt;
&lt;li&gt;Basically it contains only two things: &lt;code&gt;data&lt;/code&gt; and &lt;code&gt;next&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This &lt;code&gt;data&lt;/code&gt; can be anything, from just an &lt;code&gt;int&lt;/code&gt; to an array or dictionary.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;next&lt;/code&gt; is a pointer which points towards the next &lt;code&gt;Node&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Node&lt;/code&gt; is just a name we use for every linked entity in the linked list. Node is somewhat similar to what you have in array as an index.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lTxNWLr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2gyexd0xic6tfv9rzzi.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lTxNWLr9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2gyexd0xic6tfv9rzzi.gif" alt="Linked_Link_In_Action" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in simple words, linked list is collection of &lt;code&gt;Nodes&lt;/code&gt; linked together with pointers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why this data structure even exists?
&lt;/h3&gt;

&lt;p&gt;One may ask, we already have a linear data structure known as &lt;code&gt;arrays&lt;/code&gt; then why we created a similar but new one? Why?&lt;/p&gt;

&lt;p&gt;Then let me ask a question:&lt;br&gt;
How do you add a new element in the middle of an array?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find where you want to add new element.&lt;/li&gt;
&lt;li&gt;Add new element&lt;/li&gt;
&lt;li&gt;And shift the rest of the array one&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Linked lists solve such issues like shifting the array after adding a new element in the middle.&lt;/p&gt;
&lt;h3&gt;
  
  
  Implementation
&lt;/h3&gt;

&lt;p&gt;In python, it is really easy create some classes to reflect this data structure, like the code given below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LinkedList&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Creating from Array
&lt;/h4&gt;

&lt;p&gt;You might be wondering how can you create this linked list and see it in action.&lt;br&gt;
For this we can write a simple function to create a linked list from array and then visit every node of the linked list with another function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;createFromArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nodeList&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="n"&gt;ll&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;LinkedList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;curr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;ll&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;curr&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;curr&lt;/span&gt;

        &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;curr&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ll&lt;/span&gt;

&lt;span class="c1"&gt;# Make linked-list from array - O(n)
&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;ll&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;createFromArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Traversing
&lt;/h4&gt;

&lt;p&gt;For traversing or in simple words - visiting all nodes in a linked list we can do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;traverseList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ll&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;curr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ll&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;head&lt;/span&gt;

    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;" -&amp;gt; "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;curr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;

&lt;span class="c1"&gt;# traverse a linked-list O(n)
&lt;/span&gt;&lt;span class="n"&gt;traverseList&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ll&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you like this and want to learn more, just stick along and next we will talk about some common operations on linked list.&lt;/p&gt;

&lt;p&gt;Happy coding. &lt;/p&gt;

&lt;p&gt;Credits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cover Photo by &lt;a href="https://www.pexels.com/photo/selective-focus-photoraphy-of-chains-during-golden-hour-119562/"&gt;Joey Kyber&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Change the Approach | Different Ways to Solve Same Problem</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Fri, 24 Jun 2022 11:53:11 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/change-the-approach-different-ways-to-solve-same-problem-288l</link>
      <guid>https://dev.to/tahirraza_se/change-the-approach-different-ways-to-solve-same-problem-288l</guid>
      <description>&lt;p&gt;The way we approach a problem decides the effort its going to take to solve it. It may seem like an obvious thing but sometimes we engineers get stuck thinking in just one direction and we cannot look the other way.&lt;/p&gt;

&lt;p&gt;I would try to explain this with an example today.&lt;/p&gt;

&lt;p&gt;Let's take this simple leet code example, &lt;a href="https://leetcode.com/problems/contains-duplicate/"&gt;Contains Duplicate&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  First Approach
&lt;/h2&gt;

&lt;p&gt;Probably, the first solution in your mind is to loop over the entries in a way so that you can compare every element with the next one to check if its same and then just return true there. Sounds reasonable and also doable, let's look at the code here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;containsDuplicate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The solution actually works and is not a problem for smaller arrays to do this but as you might have guessed this is a brute force solution and the time complexity for this solution is &lt;code&gt;O(n^2)&lt;/code&gt; BigO of N-Square, because we will execute both loops n-1 times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Second Approach
&lt;/h2&gt;

&lt;p&gt;The second approach is completely different than the first one and it improves the algorithm greatly.&lt;br&gt;
In this approach, instead of comparing every element with the rest of the elements, we will keep track of all the visited elements and whenever we encounter an element which we have visited/tracked already we know we have a duplicate entry in the array.&lt;br&gt;
Some simple python code will solve it really easily.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;containsDuplicate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;visitedHashMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;visitedHashMap&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

            &lt;span class="n"&gt;visitedHashMap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach is far more efficient than the first one but it uses more memory which is &lt;code&gt;O(n)&lt;/code&gt; as we will created a hash map for storing the visited elements.&lt;/p&gt;

&lt;h3&gt;
  
  
  Second Approach - Slight variation
&lt;/h3&gt;

&lt;p&gt;Instead of checking if the &lt;code&gt;num&lt;/code&gt; key exists in the hashMap we can simply try to get the key and we know if we don't have a key, python will throw a &lt;code&gt;KeyError&lt;/code&gt; and we can pass this exception as we know there are keys which are checked for the first time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;containsDuplicate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;visitedHashMap&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;visitedHashMap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
            &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;KeyError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;visitedHashMap&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Which approach is better, I leave that judgement to you guys but I explained the above scenarios in order to build some background for the actual problem I wanted to share with you guys.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Actual Problem
&lt;/h2&gt;

&lt;p&gt;There's a relatively famous problem where you are being asked to provide the count of all possible combinations from an array of integers which adds up to a given target.&lt;br&gt;
The problem statement is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Given an array &lt;code&gt;nums&lt;/code&gt; of positive integers, provide count for all the possible combinations which adds up to a given &lt;code&gt;target&lt;/code&gt;. The combinations should have at least two elements and should be in descending order.&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: nums = [1,2,3,4], target=5
Output: 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Explanation
&lt;/h3&gt;

&lt;p&gt;For the given target &lt;code&gt;5&lt;/code&gt;, the possible combinations satisfying the above said conditions are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[4,1]
[3,2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are someone like me, you will also try to create all possible combinations which satisfy the above conditions for the given target and then just return the count of those combinations.&lt;/p&gt;

&lt;p&gt;While this is also a valid approach and it can work, there's a slight problem.&lt;/p&gt;

&lt;p&gt;Imagine if the target is &lt;code&gt;300&lt;/code&gt; and the given &lt;code&gt;nums&lt;/code&gt; array is [1,2,3,4,5,6,7,8,9,........199]&lt;br&gt;
Can you imagine how many valid combinations you can have in this case? Let's just say &lt;strong&gt;A LOT!!!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I wrote a solution in python with some dynamic programming techniques but still I was unable to calculate the combinations for even bigger numbers.&lt;/p&gt;

&lt;p&gt;After a bit of struggle I took a break - sat in my garden and reflected on my approach and realise I have to change my approach because if my current approach can only provide solution to some extent only, that can not be a valid solution.&lt;/p&gt;

&lt;p&gt;Finally, long story short, after reading a bunch of mathematics forum I found out this problem is related to a domain of mathematics called &lt;a href="https://en.wikipedia.org/wiki/Partition_%28number_theory%29#Odd_parts_and_distinct_parts"&gt;partition&lt;/a&gt; and once I understood that it was really easy to write some python code which solve the problem in really minimum time.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>Python | A simple Stack Class</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Sun, 12 Jun 2022 16:42:54 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/python-a-simple-stack-class-1nco</link>
      <guid>https://dev.to/tahirraza_se/python-a-simple-stack-class-1nco</guid>
      <description>&lt;p&gt;Today I want to talk about a famous, basic but pretty wonderful data structure we all read in our universities or colleges.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stack
&lt;/h2&gt;

&lt;p&gt;A stack is a linear data structure that follows the principle of Last In First Out (LIFO). This means the last element inserted inside the stack is removed first.&lt;/p&gt;

&lt;p&gt;You can think of the stack data structure as the pile of plates on top of another.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--I6RL7xKZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nqurmbrqcyhw1o9xra8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--I6RL7xKZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nqurmbrqcyhw1o9xra8.png" alt="stack-of-plates" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Put a new plate on top&lt;/li&gt;
&lt;li&gt;Remove the top plate&lt;/li&gt;
&lt;li&gt;And, if you want the plate at the bottom, you must first remove all the plates on top. This is exactly how the stack data structure works.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Applications
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To &lt;strong&gt;reverse a word&lt;/strong&gt; - Put all the letters in a stack and pop them out. Because of the &lt;em&gt;LIFO&lt;/em&gt; order of stack, you will get the letters in reverse order.&lt;/li&gt;
&lt;li&gt;In &lt;strong&gt;compilers&lt;/strong&gt; - Compilers use the stack to calculate the value of expressions like &lt;code&gt;2 + 4 / 5 * (7 - 9)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;In browsers&lt;/strong&gt; - The back button in a browser saves all the URLs you have visited previously in a stack.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key functions of a Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Push: Add new element&lt;/li&gt;
&lt;li&gt;Pop: Remove an element from last&lt;/li&gt;
&lt;li&gt;Peek: Get the last element without removing it&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cherry on Top
&lt;/h2&gt;

&lt;p&gt;In the following implementation instead of using built-in functions to check empty or length of stack we will use an extra variable &lt;code&gt;count&lt;/code&gt; to keep track of these things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;typing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Type&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Stack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="n"&gt;elements&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Nothing to pop!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;-=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;peek&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="ow"&gt;is&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Cannot peek an empty stack'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;elements&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;isEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Python | OOP | Classes</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Sun, 12 Jun 2022 15:55:29 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/python-oop-classes-1ac</link>
      <guid>https://dev.to/tahirraza_se/python-oop-classes-1ac</guid>
      <description>&lt;p&gt;Recently, I have realised that it is really hard for the beginners to follow the official documentations and most importantly, make sense out of it.&lt;/p&gt;

&lt;p&gt;Since Python is one of the easy to use language and a lot of people want to get started with it, I think it is a good idea to share the knowledge in plain English.&lt;/p&gt;

&lt;p&gt;For this reason, I am starting this blog post series to explain Python's object oriented model.&lt;/p&gt;

&lt;p&gt;Python's object oriented model has the following basic characteristics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is a mixture of the class mechanisms found in &lt;a href="https://en.wikipedia.org/wiki/C%2B%2B"&gt;C++&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Modula-3"&gt;Modula-3&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Classes themselves are objects. This helps for importing and renaming.&lt;/li&gt;
&lt;li&gt;Class members are public (Methods and Data Members both).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Example&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;classAttribute&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12345&lt;/span&gt;

&lt;span class="n"&gt;example&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Every class method needs to have &lt;code&gt;self&lt;/code&gt; as the first argument, which is provided implicitly by the call.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Example&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;classAttribute&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;12345&lt;/span&gt;

&lt;span class="n"&gt;example&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Example&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;example&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Aliasing: Objects have singularity, and multiple names can be bound to the same object. This is known as aliasing in other languages. Simply speaking, if you pass on object to a function as a argument and change the object inside that function, it will be changed in the main function as well.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;typing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Type&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;changeCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;
    &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;

&lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 0
&lt;/span&gt;
&lt;span class="n"&gt;changeCount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# 5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Most namespaces are currently implemented as Python dictionaries.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>guide</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What, Why! Always know the "What" and "Why".</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Mon, 30 May 2022 14:14:02 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/what-why-always-know-the-what-and-why-3h0p</link>
      <guid>https://dev.to/tahirraza_se/what-why-always-know-the-what-and-why-3h0p</guid>
      <description>&lt;p&gt;Sometimes we as programmers tend to just do stuff for the sake of completing a task which is fine in most cases but sometimes we do something without enough knowledge and break our production servers. Yes, sad but true, we do that sometimes.&lt;/p&gt;

&lt;p&gt;In today's quick blog post I just want to emphasise on one thing: Always, always know what are you doing and why are you doing that.&lt;/p&gt;

&lt;p&gt;I will try to paint the picture with some real life examples.&lt;/p&gt;

&lt;p&gt;In our day to day work we sometime encounter ourselves where we have to use a software and tweak it's configurations according to our needs. These configs are generally a common place where we seem to just bypass and do what we find first.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--79FXZ0Ga--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5f525qhj6tnmt5qdt9o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--79FXZ0Ga--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5f525qhj6tnmt5qdt9o.jpg" alt="What, why?" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most common example I can think of right now is configuring a web server according to your needs. Usually we tend to just goolge for our needs and copy-paste the first stackoverflow result.&lt;/p&gt;

&lt;p&gt;For example tweak a lot of configs for an nginx &lt;a href="https://en.wikipedia.org/wiki/FastCGI"&gt;FastCGI&lt;/a&gt; to name a few buffers, it's size param etc etc. But before you touch that piece of code make sure you know what FastCGI is, what buffers are and what does it really mean to change these configs.&lt;/p&gt;

&lt;p&gt;Another example, supervisor configs.&lt;/p&gt;

&lt;p&gt;If you have ever used supervisor (if not read &lt;a href="http://supervisord.org/"&gt;here&lt;/a&gt;) you'll know we have to configure it how it should consumer or run a command. And we can provide options like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;--limit = X&lt;/li&gt;
&lt;li&gt;--memory-limit = Y&lt;/li&gt;
&lt;li&gt;--time-limit = Z&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these configurations actually have a very meaningful impact on how supervisor should treat a command.&lt;/p&gt;

&lt;p&gt;So before you try to tweak anything in your configurations make sure you give it a few minutes to read about it and you should know why you are doing it.&lt;/p&gt;

</description>
      <category>programming</category>
    </item>
    <item>
      <title>Palindrome Number | Different techniques for detection</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Sat, 16 Apr 2022 10:08:56 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/palindrome-number-different-techniques-for-detection-40fm</link>
      <guid>https://dev.to/tahirraza_se/palindrome-number-different-techniques-for-detection-40fm</guid>
      <description>&lt;p&gt;Palindrome is a number which is same if you read if from left to right or from right to left.&lt;/p&gt;

&lt;p&gt;For example, 121 does not matter from which side you start reading it, it will remain same - 121.&lt;/p&gt;

&lt;p&gt;The problem statement looks like this:&lt;br&gt;
An integer is a palindrome when it reads the same backward as forward.&lt;br&gt;
Given an integer &lt;code&gt;x&lt;/code&gt;, return true if &lt;code&gt;x&lt;/code&gt; is palindrome integer.&lt;/p&gt;

&lt;p&gt;Whenever you encounter a problem don't jump right into the solution, instead try to think it through, try to think about the different edge cases of the problem. For example in this one, you can ask the interviewer the following questions to clarify more:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If number &lt;code&gt;0&lt;/code&gt; is a palindrome? or All one digit numbers are palindrome or not?&lt;/li&gt;
&lt;li&gt;What about negative numbers? for example 121 is palindrome but what about &lt;strong&gt;-121&lt;/strong&gt;? it will not be palindrome considering the &lt;em&gt;negative&lt;/em&gt; sign.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's assume the interviewer clarify these questions like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All one digit numbers are not palindrome.&lt;/li&gt;
&lt;li&gt;All negative numbers are not palindrome.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let's jump right into the solution.&lt;/p&gt;
&lt;h2&gt;
  
  
  First Technique
&lt;/h2&gt;

&lt;p&gt;The first solution which comes to almost everyone's mind is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Convert the number into string.&lt;/li&gt;
&lt;li&gt;Reverse the string and compare both strings.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Solution:
    def isPalindrome(self, x: int) -&amp;gt; bool:
        xString = str(x)
        return xString == xString[::-1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This solution is actually correct but it requires some extra memory to create the string and the interviewer can put a restriction not to use any extra space. So in that case this solution won't be the best one to have.&lt;/p&gt;


&lt;h2&gt;
  
  
  Second Technique
&lt;/h2&gt;

&lt;p&gt;In order to avoid the non-constant extra space usage what we can do is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Revert the integer itself&lt;/li&gt;
&lt;li&gt;And compare the integer with reverted one
So how can we do that?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's try to see with an example &lt;code&gt;5445&lt;/code&gt;.&lt;br&gt;
In mathematics we know we can get the last digit of a number by taking a 10 modulus so we keep taking the modulus and adding the number in reverted number and we will have the reverted number. And we will only revert positive numbers as we don't care about the negative ones in this case.&lt;/p&gt;

&lt;p&gt;Python code looks like this to revert a positive number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def revertNumber(x: int) -&amp;gt; int:
    if x &amp;lt; 0:
        raise ValueError('Only positive integers are allowed') 

    revertedNumber = 0

    while(x &amp;gt; 0):
        revertedNumber = revertedNumber * 10 + x % 10
        x = x // 10

    return revertedNumber
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we now have a function to revert the number so we can use this function to detect Palindromes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isPalindrome(x: int) -&amp;gt; bool:
    return x == revertNumber(x)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Final Approach
&lt;/h2&gt;

&lt;p&gt;So now we have a solution which is more efficient than creating and reverting a string.&lt;/p&gt;

&lt;p&gt;But.... we have a small issue with this problem if the reversed number is larger than &lt;code&gt;int.MAX&lt;/code&gt;, we will hit integer overflow problem.&lt;/p&gt;

&lt;p&gt;In order to avoid this situation we can change our solution a bit, instead of reversing the whole number we can just reverse the half of the number and compare it with the first half of the original number. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;5445, if we reverse the half number that would &lt;code&gt;54&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Now if we compare this &lt;code&gt;54&lt;/code&gt; it's same as the first half of the number so this is a Palindrome.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def isPalindrome(x: int) -&amp;gt; bool:
    # Special cases:
    # As discussed above, when x &amp;lt; 0, x is not a palindrome.
    # Also if the last digit of the number is 0, in order to be a palindrome,
    # the first digit of the number also needs to be 0.
    # Only 0 satisfy this property.
    if (x &amp;lt; 0 or (x % 10 == 0 and x != 0)):
        return False

    revertedNumber = 0

    while(x &amp;gt; revertedNumber):
        revertedNumber = revertedNumber * 10 + x % 10
        x //= 10

    # When the length is an odd number, we can get rid of the middle digit by revertedNumber/10
    # For example when the input is 10501, at the end of the while loop we get x = 10, revertedNumber = 105,
    # since the middle digit doesn't matter in Palindrome(it will always equal to itself), we can simply get rid of it.
    return x == revertedNumber or x == revertedNumber//10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Complexity Analysis&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Time complexity: O(log10(n)). We divided the input by 10 for every iteration, so the time complexity is O(log10(n))&lt;/p&gt;

&lt;p&gt;Space complexity: O(1)&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>python</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How you should review a PR</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Wed, 06 Apr 2022 11:50:20 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/how-you-should-review-a-pr-2d6h</link>
      <guid>https://dev.to/tahirraza_se/how-you-should-review-a-pr-2d6h</guid>
      <description>&lt;p&gt;If your day-to-day job requires you to review the pull requests from fellow engineers and you find it difficult to review then try the approach defined in this post.&lt;/p&gt;

&lt;p&gt;Reviewing a PR is actually can be a daunting experience and requires focus and time especially if you are reviewing a giant PR. Actually, before I share my thoughts on reviewing a PR, I would like you to understand how you should create one.&lt;/p&gt;

&lt;p&gt;Whenever you are coding and about to create a PR, keep in mind how would you like to review a PR and try to create a PR the way you would like it.&lt;/p&gt;

&lt;p&gt;In addition to that, I have some pointers for that.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. - Always commit a meaningful chunk of the code.
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Tip&lt;/strong&gt;: If you forgot to commit a part of code or maybe some linter issue remained uncommitted, try not to create a separate redundant commit and squash that commit into the parent commit if it makes sense.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. - Write an expressive message with your commits.
&lt;/h3&gt;

&lt;p&gt;Avoid adding comments like fixed, fix the problem, etc, and try to be more expressive, your commit message should exactly express what you did in the code.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZtGuqU3k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47b8ue274f3y7impie2g.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZtGuqU3k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/47b8ue274f3y7impie2g.gif" alt="good-vs-bad-commits" width="880" height="495"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  3. - Smaller the better
&lt;/h3&gt;

&lt;p&gt;Never create giant PRs, smaller meaningful PRs are easy on the eyes.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. - Create PR with descriptive titles and details.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NnefpCb5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e146zbrh6jtvsv6v9lao.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NnefpCb5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e146zbrh6jtvsv6v9lao.gif" alt="PR-titles" width="880" height="495"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;br&gt;
 &lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  5. - Try to add comments, and images on your PR whenever you feel it will make the reviewer's life easier.
&lt;/h3&gt;

&lt;p&gt;For instance&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you committed a big composer.lock file you can add a comment about what exactly did you updated.&lt;/li&gt;
&lt;li&gt;Maybe a new CSS change you did, try adding a screenshot of the change in views with before and after.&lt;/li&gt;
&lt;li&gt;If you commit a change in a compressed file sometimes it's hard to see the actual change and you can add a comment with the actual diff.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you keep creating PRs like this it will already improve your ability to review them.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Curiosity | A Valuable Trait for Software Engineer</title>
      <dc:creator>Tahir Raza</dc:creator>
      <pubDate>Tue, 05 Apr 2022 13:28:48 +0000</pubDate>
      <link>https://dev.to/tahirraza_se/curiosity-a-valuable-trait-for-software-engineer-4bai</link>
      <guid>https://dev.to/tahirraza_se/curiosity-a-valuable-trait-for-software-engineer-4bai</guid>
      <description>&lt;p&gt;Do you know Albert Einstein has a quote saying&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I am neither especially clever nor especially gifted. I am only very, very curious. - Albert Einstein&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This quote changed the way I think about learning new things. Now every time I want to or have to learn something new it's not a problem anymore because now I am actually really &lt;strong&gt;curious&lt;/strong&gt; about things. And in my opinion &lt;em&gt;Curiosity&lt;/em&gt; is a trait that every software engineer should have to grow as a professional.&lt;/p&gt;

&lt;p&gt;The field of software development evolves at a really fast pace, every day there is something new to learn, a new update of the packages you are using, a new security vulnerability found which you have to patch. It's like a continuously erupting volcano of knowledge all around us.&lt;/p&gt;

&lt;p&gt;For example, if you hear a word like &lt;strong&gt;Kubernetes&lt;/strong&gt; and you are curious about it you can learn something new about it today. And if you are someone like me you will start by learning the meaning of the name and where it comes from and get familiar with it quickly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pvQ0G4VI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q15kmmu7cwk6r9ch84lu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pvQ0G4VI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q15kmmu7cwk6r9ch84lu.png" alt="Kubernetes" width="512" height="512"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Like I just found out the word "Kubernetes" comes from an old Greek word for “helmsman,” (someone who steers a ship, like a container ship) which also gives a hint about the ship wheel logo. So as the name suggests it is something that steers or in other words orchestrates and it's exactly what it does.&lt;/p&gt;

&lt;p&gt;Kubernetes is an open-source container orchestration system for automating software deployment, scaling, and management. Google originally designed Kubernetes.&lt;/p&gt;

&lt;p&gt;If you curious key term in this definition of Kubernetes leads to learn something new for example these words:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open-source &lt;/li&gt;
&lt;li&gt;Container&lt;/li&gt;
&lt;li&gt;Scaling&lt;/li&gt;
&lt;li&gt;Deployment&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So what's the conclusion, if you are curious you can learn something new every day and you can have fun along the way so keep learning, and keep coding. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
