<?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 Supriya Sirbi on Medium]]></title>
        <description><![CDATA[Stories by Supriya Sirbi on Medium]]></description>
        <link>https://medium.com/@supriya-sirbi?source=rss-23efc19f453------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3x80Wv5ltlqB2kFR.jpg</url>
            <title>Stories by Supriya Sirbi on Medium</title>
            <link>https://medium.com/@supriya-sirbi?source=rss-23efc19f453------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:04:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@supriya-sirbi/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[Gems in an Unknown Land]]></title>
            <link>https://medium.com/afwp/gems-in-an-unknown-land-6daaeaf107f9?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/6daaeaf107f9</guid>
            <category><![CDATA[humanity]]></category>
            <category><![CDATA[creative-writing]]></category>
            <category><![CDATA[beyourself]]></category>
            <category><![CDATA[storytelling]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Fri, 03 May 2024 13:13:13 GMT</pubDate>
            <atom:updated>2024-05-03T13:13:13.089Z</atom:updated>
            <content:encoded><![CDATA[<p>The story of Humanity at unknown places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FNbd_lfZNbVWwoIV" /><figcaption>Photo by <a href="https://unsplash.com/@kadh?utm_source=medium&amp;utm_medium=referral">Kira auf der Heide</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I arrive at the boarding gate to take the next flight to UK. I am dressed in my formal attire all set to explore an unknown world. Solo travel hasn’t been something new to me or my family. My family members are scared yet happy to know that I would be travelling and exploring a new world. Travelling solo for a women has always been a taboo in India. People still consider it as something very bold for a woman and should be carefully considered. Taking all safety measures is a must when you are travelling solo. I have done it a couple of times and every time there is an element of surprise to my travel. That surprise element is a stranger who has helped me in tough situations.</p><p>As I sit down waiting for my flight, memories go down the lane on my previous visits to unknown countries. 3 countries and 3 strangers. These 3 people changed my outlook towards humanity. I met these 3 people during my solo travel.</p><p>My first solo travel was to UK. My family members were scared to send me alone to an unknown country. With all the suggestions and concerns raised by my family, I agreed and convinced them to travel solo. The D-day finally arrived. Scared on travelling solo for the first time, I boarded the flight to UK. I was going to attending an Open Source Summit at Edinburgh. Coming to a new city of Edinburgh, it was beautiful and serene with lush green trees. The people here were friendly and were welcoming. It was Spring time and there were flowers blooming around the city. After attending the summit, I left to a hotel that I had booked earlier online. It was 7PM at night and it felt as if it was like 1PM. I was alone, walking down the street and found the way to hotel. My heart was beating loudly since I was the only person walking down the street. The culture here at UK is a bit different, where the hotel owner or receptionist is not present at the hotel. The key and lock of the rooms are very different from those used in India. I had a key of the hotel door but did not know how to use it. I tried multiple times but the door did not open. I was scared and there was no one found around. At some distance there was a car parked nearby, the lights of the car were on. Gathering lot of courage, I went to the car to find a man smoking cigar. I requested him to help me out to enter the hotel since I am unable to open the lock. He looked at me and said, “Let’s go and check”. He was kind enough to get out of the car and walked towards the hotel door. He tried to open the door using my key. And to our luck, the door opened. He also showed how use the lock and key in UK work and asked me to practice it a few times. I thanked him for his timely gesture. Before I could ask more about him and talk to him, he was gone in the dark.</p><p>Second incident on my solo travel happened in Sydney, Australia. I had been there for conference again. I had taken a local train to Sydney to see around the city. When coming back, I wasn’t sure on the money remaining in the travel card. When changing train at one of the intermediate stations, the balance was just a few dollars. I realized that I needed to recharge it at the earliest. Without the recharge done, I would be caught red handed by the local police. I got scared since my next station was few minutes away from the current one and my balance was running out. I anyways took a train with heavy heart and met a stranger on a train. I asked him, “Hey I am new to this place. Can you please help me with the recharge points to get my travel card recharged?.” He gave a quick reply, “I can swipe my card at the next station instead of you”. He also gave me directions to the recharge place and offered me him his card if I wanted to use it. I denied and told him thanks for his kind gesture. I got down at the next station, hurried to the recharge point and got my travel card recharged. An unknown person asking me to use his card was something very surprising and also very overwhelming. I could not thank enough this person who helped me at the right time.</p><p>Third incident happened at the time when I was Torino, Italy. I had been to Italy for work and I wanted to see Rome. The train from Turin to Rome was 12 hours in total. I was staying in Turin and I took the first train at Turin at 6AM in the morning. I landed in Rome at around 12PM. I was happy to see the new found city. I visited the Colosseum, Vatican City and the Roman Empire. Since I was not left with much time, I took a return train on 3PM. I arrived at Turin at 9PM. I was very hungry since I could not have my lunch in afternoon due to the excitement of seeing Rome. I walked slowly in the streets of Turin, only to find no shops were open. I walked till I found a small shop, it had a closed Tag on the door but the owner of the store was still there. I entered the store with embarrassment, and asked him if I can buy something to eat. He spoke in Italian and could not understand my English. I showed him a croissant ( Italian version of a Bun ) and signaled him that I wanted to eat it. He understood my sign and gladly offered it to me. I took out few euros and wanted to give him. He denied it with a smile and told that’s fine. Tears came rolling down my eyes, as I could not hold on to my emotions. This old man came to my rescue when I was hungry and did not take a penny in return. I thanked him in English though he did not understand the language, I am sure he was able to see the emotion in my eyes.</p><p>These 3 persons, all strangers to me helped in unknown ways. These people who met me at unexpected circumstances helped me and refined that humanity still exists on this world. I met them at unknown places and came to my rescue without expecting anything in return. These memories will remain etched in my heart and will be close to me always.</p><p>The boarding gate opens, I come back to reality and take my flight to UK. Hoping again to see a new city, meet new people and maybe a new stranger who teaches the essence of humanity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6daaeaf107f9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/afwp/gems-in-an-unknown-land-6daaeaf107f9">Gems in an Unknown Land</a> was originally published in <a href="https://medium.com/afwp">a Few Words</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Look at the Tree Data Structure in C++]]></title>
            <link>https://medium.com/better-programming/a-look-at-the-tree-data-structure-in-c-49a33bc841eb?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/49a33bc841eb</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Mon, 12 Apr 2021 16:03:00 GMT</pubDate>
            <atom:updated>2021-04-12T16:03:00.590Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Trees can solve a wide variety of computer science problems</em></h4><figure><img alt="large tree with many branches in a forest clearing" src="https://cdn-images-1.medium.com/max/1024/0*-7lvI61a8B_AynL0" /><figcaption>Photo by <a href="https://unsplash.com/@veeterzy?utm_source=medium&amp;utm_medium=referral">veeterzy</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Trees<em> </em>are one of the most interesting data structures in computer science. Apart from having common names such as <em>sibling, leaves, parent, child, </em>etc., to represent them, trees can be used to solve some of the most challenging problems in computer science.</p><p>Let’s dive into the basic concept of trees, their usage in C++, and their application to some of the most important problems.</p><h3>The Concept Behind Trees</h3><p>Trees belong to the class of non-linear data structures. Unlike linear data structures, such as stacks or lists,<em> </em>where elements are stored in linear order<em>, </em>non-linear data structures store elements hierarchically. Thus the traversal of a tree or graph cannot be completed in a single run.</p><p>A typical example of a tree is shown below.</p><figure><img alt="diagram of numbered circles connected in a tree structure" src="https://cdn-images-1.medium.com/max/378/1*QtjD5Vfc0ZFyUXO4He9bwQ.png" /><figcaption>Example of a binary tree</figcaption></figure><p>The elements inside the circles are called the <em>nodes</em> of the tree. A binary tree is a data structure where every node has at most two children. The topmost node is called the <em>root </em>node. A node with no children is called a <em>leaf</em>. Here the root node is at 27. The node at 14 is the left child of node 27, and the node at 35 is the right child. Similarly, the left and right children of the parent node 14 are 10 and 19 respectively. The leaves in the above example are 10, 19, 31, and 42. The height of the tree is defined as the longest path from the root to a leaf. In the above case, the height of the tree is 2.</p><p>The advantage of trees is that memory is utilized in an efficient way. In the case of a stack, deleting a middle element is difficult since we have to shift the elements to the right of the stack. But in the case of a tree, we can delete the node <em>x</em> and modify its parent node to point to children of <em>x</em>.</p><h3>Types of Trees</h3><p><strong>Full binary tree:</strong> A binary tree is a full binary tree if every node has 0 or 2 children.</p><p><strong>Complete binary tree:</strong> A binary tree is a complete binary tree if all the levels are completely filled, except possibly the last level, and the last level has all keys as left as possible.</p><p><strong>Perfect binary tree:</strong> A binary tree is a perfect binary tree if all the internal nodes have two children and all leaf nodes are at the same level.</p><p><strong>Balanced binary tree</strong>: A binary tree is balanced if the height of the tree is O(Log n) where <em>n</em> is the number of nodes.</p><p><strong>Binary search tree:</strong> In a binary search tree, a node’s left child must have a value less than its parent’s value and the node’s right child must have a value greater than its parent’s value.</p><h3><strong>Coding Trees</strong></h3><p>The code to represent a tree<em> </em>in C++ is what is shown below. It consists of a data part and references to the left and right nodes, respectively.</p><pre>struct node {<br>   int data;   <br>   struct node *left; //Reference to left child<br>   struct node *right; //Reference to right child<br>};</pre><p>To keep things simple, let’s consider a binary search tree (BST). The basic operations that can be performed on this tree data structure are insert, search, and traversal.</p><h4>Insert an element into BST</h4><p>In the example below, we insert an element with value val<em> </em>into the tree. If val is less than the root value, the tree traversal continues to the left since val needs to be inserted in the left subtree. If val is greater than the root value, we continue with a right subtree traversal to insert the val to the right. If val is equal to the root key, we simply return the root to avoid duplicates. If the tree is empty or the tree traversal reaches the end with no result, then we call getNewNode function to get a new node.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce7ed4b09c0b30145c0027bb2c4faf0a/href">https://medium.com/media/ce7ed4b09c0b30145c0027bb2c4faf0a/href</a></iframe><h4>Tree traversal and search for an element in a BST</h4><p>To search for a key<em> </em>in a binary search tree, we check if the root value is equal to NULL. This case happens if the tree is empty or if the tree traversal reaches the end with the key not found. If the key is not present, we return NULL.</p><p>If the root value is equal to the key value, we return the root address.</p><p>In all other cases, we perform a left tree traversal if the key value is less than the root value and a right tree traversal if the key value is greater than the root value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b1ac480054e4a5eed97bbd41adcd65c/href">https://medium.com/media/8b1ac480054e4a5eed97bbd41adcd65c/href</a></iframe><h3>Applications of Trees</h3><p>Trees can be used to represent hierarchies and structural relationships in data. Also, they are efficient when it comes to insert and search with a time complexity of O(h), where <em>h </em>is the height of the tree. The subtrees can be moved around with minimum effort, unlike with several other data structures, like lists and arrays.</p><h4>Operating systems</h4><p>One of the most popular operating systems, Linux,<em> </em>makes use of a tree structure to represent its hierarchical file system. The file system in Linux is arranged in a tree as shown below.</p><figure><img alt="diagram showing tree structure in Linux" src="https://cdn-images-1.medium.com/max/791/1*dba45cSp977C5v6ghWJqGA.png" /><figcaption>File system in Linux</figcaption></figure><h4>Compilers</h4><p><em>A syntax tree </em>is a tree representation of the abstract syntactic structure of source code written in a programming language. Each node of the tree denotes a construct occurring in the source code.</p><p>A compiler constructs a syntax tree during the syntax analysis phase of the compiler. This tree is used to check if the correct syntax is followed when coding a computer program.</p><h4>Bridges and routers</h4><p>A<em> minimum weight spanning tree</em><strong> </strong>is a subset of the edges of a connected, edge-weighted undirected graph that connects all the vertices together, without any cycles and with the minimum possible total edge weight. This kind of tree is used for packet routing in bridges and routers in computer networks.</p><h4>Trie</h4><p>A<em> trie </em>is an efficient information retrieval data structure. Using a trie, search complexities can be brought to optimal limit (key length). If we store keys in a binary search tree, we need time proportional to M * log N, where M is maximum string length and N is the number of keys in the tree. Using a trie, we can search the key in O(M) time.</p><h3><strong>Conclusion</strong></h3><p><em>B-trees</em>, also called <em>self-balancing trees</em>, are used for indexing in databases for efficient information retrieval.</p><p>There are several kinds of trees in computer science which can be used for multiple purposes. Trees serve as one of the most important tools that every developer needs to know. This makes problem-solving faster and easier, especially for problems dealing with hierarchy.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49a33bc841eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/a-look-at-the-tree-data-structure-in-c-49a33bc841eb">A Look at the Tree Data Structure in C++</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Makes You a Modern C++ Programmer]]></title>
            <link>https://medium.datadriveninvestor.com/what-makes-you-a-modern-c-programmer-608fe80c61eb?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/608fe80c61eb</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[better-programming]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 14:13:47 GMT</pubDate>
            <atom:updated>2021-01-15T14:13:47.286Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Take your C++ skills to the next level by using “modern” C++</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4a5a6_xX89GMthoN" /><figcaption>Photo by <a href="https://unsplash.com/@heftiba?utm_source=medium&amp;utm_medium=referral">Toa Heftiba</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You know the syntax and coding with C++ language. But do you know what makes you a modern C++ programmer? Is your code using the features introduced with C++ 11, 14 or 17? Are you using the Standard library Classes in your application? Are you aware of C++ <em>lambda </em>functions, <em>smart pointers</em> and expressive <em>for</em> loops?</p><p>If your answer is no, here are few tips to level up your C++ skills and make you a <em>modern </em>C++ programmer.</p><h3>1. Standard Library Containers</h3><p><em>Vector</em>, <em>Array</em> and <em>List</em> are the basic library containers used in C++.</p><p><em>Vector </em>allocates the memory in heap, so elements can be dynamically added and deleted. It is useful when the size of container is unknown and can change at runtime.</p><p>If the size of the container is fixed ex. Months of a year (12), go ahead and use a <em>std:array </em>instead. Unlike <em>Vector</em>, <em>Array </em>allocates the memory in stack and is faster for element access.</p><p><em>List </em>is helpful for sequential element access ex.Storing the list of orders sorted by date. In the worst case, it requires to traverse the end of list for element access.</p><p>In addition to these, C++ also provides other standard library containers such as <em>stack</em>, <em>queue</em>, <em>dequeue</em>, <em>priority_queue</em>, <em>map</em>, <em>unordered_map.</em></p><p><em>Stack </em>is useful for push, pop, top operations on elements in container.</p><p><em>Queue </em>is useful to push, pop and perform other operations on elements at front of the queue only.</p><p><em>Dequeue </em>similar to<em> a queue </em>but<em> </em>performs operations on elements at front and back of the queue.</p><p><em>Priority Queue </em>similar to<em> a queue </em>but inserts an element in the container based on the priority associated with them ex. insert students based on the rank</p><p><em>Map </em>is used to store key and value pairs sorted by key values.</p><p><em>Unordered Map </em>is used key and value pairs without sorting.</p><p>If you are a beginner to C++, start with using <em>vector</em>. If you feel you need a <em>stack</em> or a <em>map</em>, go ahead and start using these containers. Also write your code in such a way that makes switching between containers easier example using keyword <em>auto</em>. In future if you want to switch from <em>dequeue </em>to <em>queue</em>, it makes it a lot easier.</p><h3>2. Lambdas</h3><p>In older versions of C++, <em>function pointers</em> were used to store a function behavior inside a variable. The function was later accessed using the pointer. The disadvantages of function pointers is that it was difficult to understand and the readability was poor. So they came up with <em>lambdas </em>which replaces traditional function pointers. All modern programming languages like Java, Kotlin using <em>Lambdas</em>.</p><p>The example of lambda in C++ is the below</p><pre>[](){} // Empty Lambda function</pre><p>Where [] represents the capture clause for capturing values, () represents the parameters passed to the function and {} contains the body of lambda function.</p><pre><em>//Example Lambda function isOdd</em><br>auto isOdd = [](int candidate){ return candidate % 2 != 0 }; </pre><pre>bool is3Odd = isOdd(3); //Returns true as 3 is Odd<br>bool is4Odd = isOdd(4); //Returns false as 4 is Even</pre><pre>vector nums{2, 3, 4, -1, 1};<br>//Find the number of Odd Items in the Vector. Returns 3<br>int odds = std::count_if(begin(nums), end(nums), isOdd);</pre><p>In the example above, <em>isOdd </em>is a lambda function to check if the input number is Odd. <em>Lambdas </em>can be used with <em>for_each</em>, <em>count_if</em> and other standard library functions and suddenly these libraries become useful with it.</p><p>The advantages of using lambdas is that — they can be used to form certain generic work, helps to achieve concurrency and increases the readability of the code.</p><h3>3. Standard Library Algorithms</h3><p>The <em>algorithm </em>library in C++ defines functions that can perform several operations example sorting, counting, manipulating, finding elements in the containers etc. The developer need not write any code for them and saves time to focus on other parts of the code.</p><p>Example of standard library algorithms <em>swap, sort and count_if </em>is given below</p><pre><em>//Example of Swap function for a and b<br>int a = 5;<br>int b = 8;<br>swap(&amp;a, &amp;b);</em></pre><pre>//<em>Example of sort function. Sort elements in ascending order<br>vector&lt;int&gt; v{5, 3, 4, 2, 1};<br>sort(v.begin(), v.end());</em></pre><pre>//Count the number of 3’s in the vector v<br>int num_items3 = std::count_if(v.begin(), v.end(), [](int i){return i == 3;});</pre><p>There are tons of standard library algorithms that can be used. Advantages of using them include — They make the code more readable and expressive like, everyone understands what a <em>sort </em>function does. Also not having to write them from scratch saves you time, effort and all the headache involved in handling the edge cases. It also makes the developer easy to switch containers since most of the algorithms use <em>Iterators </em>for accessing the elements. Since Iterators can be used with any containers, when the developer changes from <em>stack </em>to <em>queue, </em>code changes would be minimal.</p><p>The biggest challenge for the developer would be to <em>find </em>the right algorithm for the code and <em>learning </em>to implement them.</p><h3>4. Exceptions</h3><p>It is quite natural for the program to throw errors or cause failure at runtime. While some might be predictable, some may not be so. Also different types of errors need to handed in different ways. In some cases, the developer might forget to handle error cases. To handle unusual and exceptional errors, <em>exceptions </em>are used.</p><p><em>Exceptions </em>in C++ contain 3 main pieces</p><ul><li><em>Try — </em>This block needs to be as small as possible to check for the code that throws an <em>exception</em></li><li><em>Throw —</em> It can throw exceptions from <em>std::exception</em> class</li><li><em>Catch —</em> Block of code used to catch exceptions. The exceptions need to be ordered from most specific exceptions at the top, to general ones at the bottom.</li></ul><p>Example of an <em>Exception</em> is shown as below</p><pre>//Example of Divide by Zero exception thrown<br>void func(int a, int b)<br>{<br>  try {<br>    if( b == 0 ) throw std::invalid_argument(&quot;b is zero&quot;);<br>    else a/b;<br>  }<br>  catch(std::exception&amp; e){<br>    //Handle Exception here<br>  }<br>}</pre><p>The advantages of using exceptions is that between the try and catch block, the locally scoped objects are cleaned up automatically, by calling their destructor class. So the <em>finally </em>block is not required in C++ unlike other programming languages. Also the <em>std::exception</em> class is very helpful. Most standard library code throws objects derived from this class. Also when there is a chain of function calls like <em>a </em>calls <em>b</em>, <em>b </em>calls <em>c</em> …. <em>y </em>calls <em>z</em>, returning error from <em>z </em>back to <em>a </em>is pretty frustrating. It takes lot of time and affects performance. In such cases, exceptions can be used in <em>z </em>to handle errors.</p><p>In summary, <em>modern C++</em> is expressive and readable. It helps the developer use the power of language to express the intent and minimize efforts required for coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=608fe80c61eb" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/what-makes-you-a-modern-c-programmer-608fe80c61eb">What Makes You a Modern C++ Programmer</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started With Android App Development]]></title>
            <link>https://medium.datadriveninvestor.com/getting-started-with-android-app-development-8f1814bd5266?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f1814bd5266</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Tue, 05 Jan 2021 03:56:21 GMT</pubDate>
            <atom:updated>2021-02-04T14:01:37.108Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Tips to start with your first Android App</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jgoHVoH2NPlbG-15" /><figcaption>Photo by <a href="https://unsplash.com/@mbaumi?utm_source=medium&amp;utm_medium=referral">Mika Baumeister</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I have been an Android Developer past 5 years from now. Some of the questions I get from my fellow Developers is on <em>How to get started with Android App Development? What are the basics I need to know?</em></p><p>Based on my App Development Experience, I will try to share 5 basic tips to start on your Android App Development Journey.</p><h3><strong>1. Install Android Studio</strong></h3><p>This is the most important and mandatory step to start developing <em>Android Apps</em>. I have seen developers who jump start into reading docs for developing apps. Though reading documentation is good, I personally recommend to <em>Install Android Studio</em> first. This will help you to practice few tasks when you are reading docs in future. Android Studio can be installed from the link — <a href="https://developer.android.com/studio"><em>Install Android Studio</em></a><em>. </em>When the Android Studio setup is complete, create an <em>Emulator </em>device to run your first Android App in Android Studio. For more information on creating an Emulator device in Android Studio use this <a href="https://developer.android.com/studio/run/managing-avds">link</a>.</p><h3>2. Android Architecture</h3><p>Next try to understand the history of Android and what Android Stack is composed of. The Platform Architecture of Android looks like the below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g8x1Uic5671J7DgNtDUz6w.png" /><figcaption>Platform Architecture of Android( <a href="https://developer.android.com/guide/platform">https://developer.android.com/guide/platform</a>)</figcaption></figure><p>Here the Linux Kernel is at bottom of Android Stack. Above the kernel is the HAL layer which helps to abstract the kernel API’s for Audio, Bluetooth etc. Above the HAL Layer are the Native C++ Libraries like OpenGL ES for Audio and Video Rendering, Webkit for Browser functionality etc. Android Runtime provides a JAVA Virtual Machine for running Android Apps. The Java API Framework provides JAVA libraries for Audio, Bluetooth and other Applications. All Apps make use of this framework to achieve their functionality. Example Audio Applications make use of Mediaplayer API’s in Java Framework for Audio Streaming.</p><h3>3. Understand App Components</h3><p>The next step would be to understand Android App components. There are 5 major App Components in Android — Activity, Fragment, Service, Broadcast Receiver and Content Providers. Any Android App can be composed of single or multiple components from these 5 categories. Understanding each of these 5 components helps to make Android App Development simpler. A brief description of each of these components are as given below</p><p><strong><em>Activity </em></strong>— It is one screen in Android App User Interface. An App can have one or multiple activities.</p><p><strong><em>Fragment </em></strong>— It is part of an Activity and represents reusable portion of App User Interface.</p><p><strong><em>Service </em></strong>— It is used for performing long-running background tasks. It does not provide a user interface.</p><p><strong><em>Broadcast Receivers</em></strong> — It is used for receiving broadcast messages from other apps or from Android system.</p><p><strong><em>Content Providers </em></strong>— It is used to manage access to data stored by itself, stored by other apps, and provide a way to share data with other apps.</p><p>These components are defined in the Android App’s <em>AndroidManifest.xml </em>file.</p><h3>4. Understand UI Design Elements</h3><p>Understanding the design elements of your App plays a major role in attracting users to your App. The look and feel of the app can make the user download the application. The App layout and the way UI elements are organized in the App Screen, decides if user is going to use the App in future. A bad UI design where the design icons are confusing to the user can lead to poor app usage. So deciding the App layout and the Views to be used for App Development is a major decision.</p><p><strong><em>View</em></strong> represents the basic building block for user interface components. Examples include</p><p><strong><em>TextView</em></strong> used to create Text Elements.</p><p><strong><em>Buttons </em></strong>used to create Android Buttons.</p><p><strong><em>ImageView</em></strong> used to create Image Icons.</p><p>The <em>layouts</em> or <em>View Groups</em> is the sub class of <em>View</em> class, also called a<strong><em> V</em></strong><em>iew Container. </em>Some of the layouts used in Android App are</p><p><strong><em>Linear Layout</em></strong> — Organizes Views in a linear fashion: <strong>vertically or horizontally.</strong></p><p><strong><em>Relative Layout </em></strong>— Views placed relatively to other Views.</p><p><strong><em>Frame Layout</em></strong> — Used to <strong>stack up </strong>or<strong> pile Views </strong>one above the other.</p><p><strong><em>Constraint Layout </em></strong>— Used to create complex views.</p><p>These layout elements and views are defined as part of the App resource directory — <em>res</em>. This directory contains the XML resource files that are part of UI design.</p><h3>5. Wrapping all this together</h3><p>The last step is to understand how all App components, UI design elements, the Android Studio tools like Gradle and Emulator, the Android Architecture Framework elements come together to create your first Android Application.</p><p>To better understand these components, you can build the Android Application in Android Studio. When the App is building, check for the <em>Build </em>Console logs in Android Studio. It shows how the app components and the resources are getting linked. Finally run your first Android Application on your <em>Emulator</em> device. Check for <em>Logcat </em>logs in Android Studio to debug your Android Application further.</p><p>You are now ready to start developing your first Android App!</p><p><strong>Gain Access to Expert View — </strong><a href="https://datadriveninvestor.com/ddi-intel"><strong>Subscribe to DDI Intel</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f1814bd5266" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/getting-started-with-android-app-development-8f1814bd5266">Getting Started With Android App Development</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Tips To Becoming A Good Software Developer]]></title>
            <link>https://medium.datadriveninvestor.com/5-tips-to-becoming-a-good-software-developer-7acd54426547?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/7acd54426547</guid>
            <category><![CDATA[software]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Thu, 01 Oct 2020 11:20:56 GMT</pubDate>
            <atom:updated>2021-01-05T11:13:41.013Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 Things I Learnt As A Software Developer</h3><p><em>Few tips to succeed in your programming journey</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6PXDOxCo9x0Hjrf8" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=medium&amp;utm_medium=referral">Kelly Sikkema</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I have been working in the tech industry for close to 7 years now. I am enjoying every bit of my journey as a Software Developer. Though I am not the best developer, there are few important lessons that I have learnt in my role as a <em>Software</em> <em>Developer</em>. These lessons have enriched my developer journey and helped me to seek out on my journey of becoming a <em>Good Developer.</em></p><h3>1. Understand the System</h3><p>The first step to becoming a good developer is to understand what is expected of you. It involves understanding what is the system that you would be working on, what are the dependencies to it, what are the interactions of the system with other components, what are the metrics for system performance, what makes the system to fail and so on…<em>Understanding the system</em> is possible when we make an attempt to question the existing requirements for the system. In my career, I have met a few people who blindly jump into coding without questioning the system in front of them. And the reverse is also true where some people were very much interested in understanding the system. Going back to a point where I started my career, my habit for asking more information and trying to understand overall system behavior helped me gain enough exposure to existing systems and make better decisions.</p><h3><strong>2. Focus on Design</strong></h3><p><em>Why should I know the Design of the System or spend time developing a Sequence Diagram?</em> is the question some developers ask today. As per the software life cycle, this phase is carried out by System Architects of a company and the developers need not break their brains into understanding it. Until there is a QA(Quality Assurance) team who comes up to check it, I see most people are ignorant or never think about it until the last minute. To become a good developer, I feel understanding the system design is very important. Whenever there is a system failure or customer issue, this information would come handy for debugging. If you are concerned only about your own module, it makes debugging tougher. Also blinding writing code without knowing the design makes you a poor programmer. Developing a simple design for the module you are working on, helps you to reduce training time when a new developer takes up your work or when you have to reference it in future.</p><h3>3. Write Efficient Code</h3><p>In my experience, understanding the system and it’s design prior to jumping into code makes coding faster. Since you know the system, it’s design and the interaction with other components, you can find common design patterns that you can use while writing code. Also you can compare systems that have similar design and check out on how previous developers have coded them. The magic formula for being a good programmer is writing <em>Simple, Clean and Efficient </em>code. <em>Simple Code</em> means code that can be understood by all. <em>Clean code </em>is<em> </em>all about<em> </em>using proper variable names, prevent lengthy loops and code, using modularization and following basic OOP(Object Oriented Programming) principles. <em>Efficient Code</em> means thinking about reusability i.e how the software module can be used for other similar systems and maintainability i.e what happens when some feature changes, needs to be understood during coding process.</p><h3>4. Test what you code</h3><p>Developing Unit Tests and Performing Integration Tests are often underestimated by most developers. Most people I talk to either shrug off saying these tasks need to be done by the Integration team or we will look into them after development is complete since they lack enough time. I have also made some of these mistakes previously and learnt that these tests save time for future. They improve your code quality and make you a good developer. Writing unit tests for your code, needs to be done everyday and be in line to software development process. Also integrate the system and test it before release. This reduces software and customer issues reported in future.</p><h3>5. Be open to Learning</h3><p>My last piece of advice to all developers reading this is to learn every single day. You never know when you will be out of work or when you get a cool opportunity that you ever wanted. Apart from these reasons, learning every single day will make you outperform at work and improve your efficiency. Learning also helps one to keep up with the current technology trends. Take up a piece of article or just read a few minutes in your area of interest everyday, you would be astonished on how much you have gained after few months.</p><blockquote>I am still learning — Michelangelo at age 87</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7acd54426547" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/5-tips-to-becoming-a-good-software-developer-7acd54426547">5 Tips To Becoming A Good Software Developer</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Importance of Hash Maps]]></title>
            <link>https://medium.com/better-programming/the-importance-of-hash-maps-831884307806?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/831884307806</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Mon, 24 Aug 2020 15:42:23 GMT</pubDate>
            <atom:updated>2020-08-24T15:42:23.191Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Hash maps can solve a whole bunch of different problems</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xs9VIqM97YsDa0HJ" /><figcaption>Photo by <a href="https://unsplash.com/@hjrc33?utm_source=medium&amp;utm_medium=referral">Héctor J. Rivas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>Hashing is a traditional approach in computer science whereby data structures called hash maps are used to store key-value pairs<em>. </em>Apart from storing key-value pairs, hash maps can be used to solve a wide variety of problems in computer science. When used with priority queues and other container adapters like stacks and queues, hash maps can make problem-solving faster by reducing the running time complexity.</p><p>Let’s dive into the basic concept of hash maps, their usage in C++, and applications to some of the most important problems.</p><h3><strong>The Concept Behind Hash Maps</strong></h3><p>Hash maps generally store elements as key-value pairs. Consider this example: We want to store a list of grocery items with their prices into hash maps. The name of the item serves as a key and its price is the value. This key-value pair is stored into a hash map, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*xKFm8S0guRV3X1OLzzrPGw.png" /><figcaption>Items with prices stored in unordered maps.</figcaption></figure><p>The order of storing the key-value is not guaranteed in an Unordered Hash Map (also called an Unordered Map). When we insert an item into an Unordered Hash Map, it can reside at any position in the Map object. If we want strict ordering of items in ascending order of their keys, we can use an Ordered Hash Map or simply Maps. For the same example as above, this is how the items are stored in Maps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*kWrMUOlhM1waroBJlWgR9A.png" /><figcaption>Items with prices stored in Maps.</figcaption></figure><p>The keys are sorted in lexicographic<em> </em>order starting with the smallest letter, <em>c</em>. When a new item like Juice<em> </em>with a price of<em> </em>$12<em> </em>needs to be added to Maps, it is inserted at position 3 after<em> </em>Chocolate<em> </em>to maintain the lexicographic order<em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/182/1*2khxOC-FczvfFUKV6t4aIg.png" /><figcaption>Juice<strong> </strong>added to Maps.</figcaption></figure><h3>Coding Hash Maps</h3><p>Unordered maps and Maps are part of Standard Template Libraries(STL) in C++. To declare Maps and Unordered Maps<em>,</em> run the following:</p><pre>map&lt;key_type, value_type&gt;mp;</pre><pre>unordered_map&lt;key_type, value_type&gt;unmp;</pre><p>key_type and value_type can be of standard data types such as int, float, char, pair, etc.</p><p>Most of the member functions are common for unordered_map and map object. So let’s look at some of these functions.</p><h4><strong>1. Inserting an item into a hash map</strong></h4><p>To insert an item into unordered_map or map, run this:</p><pre>mp.insert(pair&lt;key_name, value&gt;);</pre><p>key_name and value<em> </em>are the item name and value to be inserted in map, respectively. In the example above, we have Carrots<em> </em>as the key_name<em> </em>and $2<em> </em>as the value<em>. </em>We can also insert the item using the assignment operator:</p><pre>mp[&quot;Carrots&quot;] = 2;</pre><h4>2. Delete an item from a hash map</h4><p>To delete an item from a hash map, we use the erase<em> </em>function:</p><pre>mp.erase(mp.begin()); //Delete an item at start</pre><pre>mp.erase(&quot;Carrots&quot;); //Delete an item with key &quot;Carrots&quot;</pre><pre>mp.erase(mp.begin(), mp.end()); //Delete all items in the map</pre><h4>3. Find an item in a hash map</h4><p>To find an item in a hash map, we use the find<em> </em>function:</p><pre>const_iterator itr = mp.find(&quot;Carrots&quot;);</pre><p>If Carrots<em> </em>is found in the map, then itr<em> </em>contains the iterator to the element in the hash map. If the specified key is not found, itr<em> </em>contains the value of unordered_map::end.</p><h4><strong>4. Other hash map functions</strong></h4><p>Here are some of the other common functions used in hash maps:</p><pre>value = mp.at(&quot;Carrots&quot;); //Returns the value at key </pre><pre>cnt = mp.count(&quot;Carrots&quot;); //Returns the total number of carrot</pre><pre>is_empty = mp.empty(); //Returns if the Hash Map is Empty</pre><pre>total_size = mp.size(); //Returns the total number of items</pre><h3>Applications of Hash Maps</h3><p>One of the biggest advantages of using hash maps is that they provide a constant time of <em>O(1)</em> for search, insert, and delete operations. This makes them more suitable for problems related to finding duplicates, finding the frequency of items, and finding distinct elements.</p><h4><strong>1. Problems related to item frequency</strong></h4><p>Hash maps are useful for solving most problems related to item frequency. An example of such a problem is finding common characters in a list of strings. If an item appears twice in all strings, it needs to be included twice in the output:</p><pre><strong>Input: </strong>[&quot;bella&quot;,&quot;label&quot;,&quot;roller&quot;]<br><strong>Output: </strong>[&quot;e&quot;,&quot;l&quot;,&quot;l&quot;]</pre><p>To solve this problem, we can use two for<em> </em>loops to compare one string with a list of other strings. But the time complexity of such an approach is <em>O(n²)</em>. To minimize the time complexity, we can use a hash map to store the characters as keys with the string number and frequency as a pair for value. We can then iterate the hash map to check for common characters found in all strings along with their frequency. This reduces the time complexity to <em>O(n)</em>.</p><h4><strong>2. Dictionary</strong></h4><p>A dictionary is another common example where hash maps are used more frequently. If we were to make an online portal for searching the meaning of a word, we would be building a dictionary<em> </em>in the back end<em> </em>to store the word along with its meaning. When a user searches for a word, it uses the find<em> </em>hash function to retrieve its meaning.</p><h4><strong>3. File systems</strong></h4><p>Hash maps are used to link the file name with the path of the file. To store the correspondence between the file name and path and the physical location of that file on the disk, the system uses a map. That map is usually implemented as a hash table.</p><h4><strong>4. Password verification</strong></h4><p>Consider a web application that allows user login and authentication when a user enters their username and password<em>. </em>In most modern systems, the username and password are not sent as plain text to the back-end server for authentication. Instead, they are encoded as a hash value and sent to the server. The server then checks the received hash value with the stored hash value. If there is a match, the user is allowed to log in. Special cryptographic functions are used for this purpose, so the user is secure.</p><h4><strong>5. Storage optimization in the cloud</strong></h4><p>Dropbox<em> </em>uses hash tables for storage optimization in the cloud. Suppose there are multiple users who upload the same video to their Dropbox<em> </em>accounts. Since storing multiple copies of the same video will consume too much storage, Dropbox stores a single copy of the file with the link provided to each user for access. When a new user uploads the same file, Dropbox<em> </em>computes the hash value for the file. If it matches the value stored in the hash table, the user is returned the link to the file.</p><h4><strong>6. Compiler operation</strong></h4><p>To identify the keywords in a programming language, the compiler stores them in a hash table. The compiler then checks the program with the hash table to verify if the program syntax is correct.</p><h3>Conclusion</h3><p>These are just a few applications using hash maps. Hash maps serve as one of the most important tools that every developer needs to know. This makes problem-solving faster and easy — especially problems dealing with item frequency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=831884307806" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/the-importance-of-hash-maps-831884307806">The Importance of Hash Maps</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Importance of Priority Queues]]></title>
            <link>https://medium.com/better-programming/the-importance-of-priority-queues-f87e1f5ac842?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/f87e1f5ac842</guid>
            <category><![CDATA[computers]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Wed, 01 Jul 2020 15:36:07 GMT</pubDate>
            <atom:updated>2020-07-01T15:36:07.494Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Priority queues can solve a whole bunch of different problems</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kenwxbETshLnNBEZ" /><figcaption>Photo by <a href="https://unsplash.com/@levidjones?utm_source=medium&amp;utm_medium=referral">Levi Jones</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>Priority queues<em>, </em>also called heaps,<em> </em>are an oft-misunderstood and underestimated concept in computer science. Though they are very simple, priority queues can serve as powerful tools to solve some of the well-known problems in computer science.</p><p>This article focuses on the basic concept of priority queues, their usage in C++, and applications to some of the most important problems.</p><h3>The Concept Behind Priority Queues</h3><p>As the name suggests, a priority queue<em> </em>contains elements having a priority associated with them. Let’s start by taking a simple example.</p><p>Consider we have a list of grocery items and a priority attached to them. Let’s associate them as key-value pairs inserted into a priority queue, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*rOhy-6n3zGKMC6-ELHMV0A.png" /><figcaption>List of grocery Items with priority</figcaption></figure><p>Tomatoes are at the top of the queue and have the highest priority, followed by Noodles, Rice, and Wheat<em>. </em>Let’s say<em> </em>we want to push an item called Cake<em> </em>with priority equal to<em> </em>10<em>.</em>When we push Cake into the priority queue, the queue checks if the item has a priority greater than that of Tomatoes (7). If yes, then it is inserted at the top of queue. The new queue is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*Gs9YSUkWhwlOAVaaYXxm0w.png" /><figcaption>Cake added at the top of the priority queue</figcaption></figure><p>Now let’s say we want to push another grocery item (Chocolate)<em> </em>with priority equal to 2. In this case, the priority of Chocolate (2) is lower than the priority of Cake (10). So the queue pops the item Cake and checks for the next item Tomatoes (7). The case is similar to Cake — the queue pops out Tomatoes. The same rule applies to Noodles (5) and Rice (3).</p><p>The queue now contains a single item, Wheat (1), at the top of the queue. Cake (2) has a higher priority than Wheat (1), so it is placed at the top of the queue. The items that were popped out of the queue are placed back in Last Out, First In order. So Rice, Noodles, Tomatoes, and Cake are placed back in the priority queue, as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*LCMdc7grxIAWk264-NMfdQ.png" /><figcaption>Priority queue with Chocolate inserted in between</figcaption></figure><p>The idea of a priority queue is simple. Insert the items into the queue based on priority and<em> </em>pop out the item with the highest<em> </em>priority from the top of the queue.</p><h3><strong>Coding Priority Queues</strong></h3><p>Priority queues are part of Standard Template Libraries (STL) in C++. They belong to the basic group of container adapters like stacks and queues. They are declared like so:</p><pre>priority_queue&lt;type&gt;pq;</pre><p>Type denotes any variable type, like int, char, float, etc.</p><p>By default, the element with the highest value (priority) resides at the top of the queue. All elements reside in the queue in decreasing order. If we want to have the element with the lowest value at the top of the queue and elements sorted in increasing order, then change the declaration:</p><pre>priority_queue&lt;type, greater&lt;type&gt;&gt;pq;</pre><p>In case we want to have our own custom ordering for elements in a priority queue, then declare the priority queue with the custom function myOrder:</p><pre>priority_queue&lt;type, vector&lt;type&gt;, myOrder&gt;pq;</pre><p>The custom function needs to be part of a struct or class with the name myOrder<em>. </em>Suppose we want to return the element with the highest value at the top of the queue. Then we’d return<em> </em>p1.val &lt; p2.val.</p><pre>struct myOrder{ </pre><pre>bool operator()(type const&amp; p1, type const&amp; p2){ </pre><pre>//Write your own custom order function. For example, we order elements in decreasing order and return element with the highest value. </pre><pre>return p1.val &lt; p2.val; </pre><pre>} </pre><pre>};</pre><p>To push an element into the priority queue<em> </em>pq,<em> </em>we use:</p><pre>pq.push(item);</pre><p>Similarly, to pop an item from the priority queue, we use:</p><pre>pq.pop();</pre><p>To access the element at the top of the queue, we use:</p><pre>type item = pq.top();</pre><p>To check the size of the queue, we use:</p><pre>size_type t = pq.size();</pre><p>To check if the priority queue is empty, we use:</p><pre>bool is_empty = pq.empty();</pre><p>Other functions, such as emplace and swap, are used to insert new items and swap with other priority queues.</p><h3>Applications of Priority Queues</h3><h4>1. Sorting heaps</h4><p>One of the classic problems in this category is finding the top <em>k</em> frequent items<em>. </em>Given a non-empty list of words, return the <em>k</em> most frequent elements. Since the answer needs to be sorted in descending order, we use max heap for this purpose:</p><pre><strong>Input:</strong> [&quot;the&quot;, &quot;day&quot;, &quot;is&quot;, &quot;sunny&quot;, &quot;the&quot;, &quot;the&quot;, &quot;the&quot;, &quot;sunny&quot;, &quot;is&quot;, &quot;is&quot;], k = 4<br><strong>Output:</strong> [&quot;the&quot;, &quot;is&quot;, &quot;sunny&quot;, &quot;day&quot;]<br><strong>Explanation:</strong> &quot;the&quot;, &quot;is&quot;, &quot;sunny&quot; and &quot;day&quot; are the four most frequent words,<br>    with the number of occurrence being 4, 3, 2 and 1 respectively.</pre><p>The solution to this problem involves using unordered maps to store the word as a key and frequency as a value<em>. </em>We push the<em> </em>words into the priority queue based on the<em> </em>frequency<em>. </em>The word with the highest frequency is stored at the top of the queue. We then pop the words from the queue and return the result.</p><p>Other examples of a sorting heap are <em>k</em> closest points to origin, <em>kth</em>-largest element in stream, <em>kth</em>-smallest element in sorted matrix, find <em>k</em> pairs with smallest sum, etc.<em> </em>Also, heap sort — a classic sorting algorithm — uses a priority queue for sorting elements.</p><h4>2. Load balancing</h4><p>Another classic problem where heaps play an important role is load balancing<em>. </em>Load balancing is a computer networking method that involves distributing the workload across multiple computing resources. Consider <em>n</em> servers in a distributed environment that are responsible for performing several tasks. Suppose there is a new request coming from a user. The request needs to be routed to a server that has a minimum workload and maximum threshold. The servers that are overloaded have a threshold value &lt; 0.</p><p>To solve such a problem, we use max heap<em> </em>to store<em> </em>threshold values<em>. </em>The server that has the maximum threshold and minimum load is stored at the top of the priority queue. This server is popped out of the queue and responsible for executing the new user request.</p><h4>3. Data compression</h4><p>Huffman coding is a lossless data compression algorithm where each character in the data is assigned a variable-length code. The least frequent character gets the largest code and the most frequent one gets the smallest code. Encoding the data in this way is easy and efficient. Using priority queues for storing characters with frequencies and max heap trees to compress the data can help solve this problem. JPEG and MP3 multimedia codecs use Huffman coding for data compression.</p><h4>4. Graph algorithms</h4><p>Dijkstra’s Shortest Path algorithm<em> </em>and<em> </em>Prim’s algorithm<em> </em>are well known for finding the shortest path from source to target. We need to store the adjacency matrix for the nodes along with the cost of travel from <em>node i</em> to <em>node j. </em>Min heap<em> </em>can be used to store the path and the cost associated with it. The path with the minimum cost is at the top of the priority queue. It pops out and is used to calculate the minimum path from the source to target node.</p><h4>5. AI algorithms</h4><p>The A* Search algorithm is one of the best and most popular techniques used in pathfinding and graph traversals in the field of AI. The priority queue, also called a fringe<em> </em>in the A* Search Algorithm, keeps track of unexplored routes in a game. The lowest-bound route on the total path length (i.e. the one with the shortest path) is given the highest priority. It is stored at the top of the queue. This route is used in the game for future pathfinding.</p><p>These applications are just a few examples using priority queues. The scope of usage of priority queues is wide. It is currently being used in several domains. Thus priority queues, a foundational concept in computer science, can serve as powerful tools for solving some of the most interesting problems.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f87e1f5ac842" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/the-importance-of-priority-queues-f87e1f5ac842">The Importance of Priority Queues</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 10 Things You Can Try On Your Daily Commute]]></title>
            <link>https://medium.com/afwp/top-10-things-you-can-try-on-your-daily-commute-506faa953f92?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/506faa953f92</guid>
            <category><![CDATA[work]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[traffic]]></category>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[office]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Thu, 04 Jun 2020 15:31:01 GMT</pubDate>
            <atom:updated>2020-06-04T15:31:01.357Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Few tips to change your mindset and enjoy your commute time</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ODKLDBq23bUCpjco" /><figcaption>Photo by <a href="https://unsplash.com/@itsmelb?utm_source=medium&amp;utm_medium=referral">Melanie Brown</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Commute can be painful in metro cities like Bengaluru which have highest traffic congestion in the world. Since I commute to office every day, I found few ways to enjoy my commute time.</em></p><p><strong>So here are the top 10 things I did to enjoy my daily commute.</strong></p><p><strong>1. Relax and Meditate</strong></p><p>Meditation is known to calm your mind and bring peace within yourself. Spending 10 minutes of your daily commute time in practicing meditation can reap huge benefits. It improves emotional health and controls anxiety.</p><p><strong>2. Learn something new</strong></p><p>With the launch of several online portals, any person who has access to Internet, can learn from anywhere in the world at any time. Learning something new every day keeps your mind active, can make you a more interesting person, fight boredom and keep up with technological advances.</p><p><strong>3. Pursue your hobbies</strong></p><p>Hobbies provide an outlet for stress and promotes staying present. There are some hobbies like knitting, craft etc. which can be pursued and practiced during daily commute.</p><p><strong>4. Socialize</strong></p><p>With the advent of mobile phones and Internet, there is sharp decline in networking and socializing with people around us. If you are one of them, then I would suggest to get up and talk to people around you.</p><p>Making friends with people who share your commute time can be interesting. You can learn from their stories and share yours.</p><p><strong>5. Enjoy Music</strong></p><p>Listening to music makes you happy, lowers stress and helps you sleep better. As per mental health experts, it improves memory and reduces depression. So listening to music on daily commute can have high benefits to your mental wellbeing.</p><p><strong>6. Be in touch with your close ones</strong></p><p>Making phone calls to your old friends and family during commute can provide you the necessary time to be in touch with your close ones. It is easy to get bogged down with the idea of being busy but making time for your closed ones is also important to maintain our relationships.</p><p><strong>7. Planning you day</strong></p><p>Planning your day is important in achieving your goals. Plans that are written are half executed. Set 5 minutes a day during your commute to plan your everyday tasks. Sit down with a blank piece of paper and decide what will make this day highly successful.</p><p><strong>8. Read Books</strong></p><p>The more we read, the more we understand about the world around us. Books also educate us and keep us informed. They keep our brains healthy by enhancing mental simulation. They inspire us with stories and are known to reduce stress levels.</p><p><strong>9. Think</strong></p><p>Due to our everyday busy schedules, we hardly have any time left to ponder about our own life. We don’t have time to reflect our daily actions, thoughts and emotions. Taking the necessary time for self-reflection can improve our lives and make us better humans.</p><p><strong>10. Sleep</strong></p><p>Sleep is important for good health. It is a vital and often neglected component, for a person’s wellbeing. A good sleep can improve concentration and productivity at work. Good sleepers are known to have better body weight, good emotional health and lower depression levels.</p><p><em>Rather than complaining, it is important for us to utilize our commute time in a better way. I am sure the above tips will help you to stop worrying about daily traffic and start thinking about improving yourself.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/0*2wNmaDbT3Z7CsDRr.png" /></figure><h4>This story is published in <a href="https://medium.com/afwp?source=post_page---------------------------">a Few Words</a>, Medium’s publication that only accepts stories under 500 words.</h4><h4>If you have a few meaningful words to say and want to be a writer in our publication, visit <a href="https://medium.com/afwp/write-for-us-4c370c63348a">here</a>.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=506faa953f92" width="1" height="1" alt=""><hr><p><a href="https://medium.com/afwp/top-10-things-you-can-try-on-your-daily-commute-506faa953f92">Top 10 Things You Can Try On Your Daily Commute</a> was originally published in <a href="https://medium.com/afwp">a Few Words</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Solo Traveling Teaches You]]></title>
            <link>https://medium.com/the-ascent/what-solo-traveling-teaches-you-ae0e92aef90a?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae0e92aef90a</guid>
            <category><![CDATA[inspiration]]></category>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[solo-travel]]></category>
            <category><![CDATA[travel]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Tue, 28 Jan 2020 13:16:01 GMT</pubDate>
            <atom:updated>2020-01-29T02:33:14.714Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Life lessons from a solo traveler</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zf6sNHmSCYA3xUKX" /><figcaption>Photo by <a href="https://unsplash.com/@jtylernix?utm_source=medium&amp;utm_medium=referral">Tyler Nix</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong><em>I am a solo traveler and yes I am proud of it</em></strong>. Not that I hate being around people during my travel but solo travelling has taught me very important life lessons which wouldn&#39;t be the case had I been around people.These lessons have enriched my life and added value to who I am today.</p><p>I was inspired to write this article since I feel that there is a taboo around travelling alone especially for women in society. People still feel that traveling solo is something very harmful or dangerous or selfish and I often hear ’n’ number of questions whenever I decide to travel alone. This article focuses on important life lessons that solo travelling has taught me.</p><h3><strong><em>Planning is everything</em></strong></h3><p>Most people have a fuss around managing finances and time. I often hear people say, “Oh! I am really bad at time management” or “I am drawn towards spending money ”. Travelling solo helps you to manage your finances and time better. From getting a visa to booking air-tickets, hotels and planning your schedule to see the important places around the city at the important times, you get to understand the importance of planning. I was not so good at managing my schedules, but travelling has taught me the art of managing money and time well.</p><h3><strong><em>Your soul experiences joy</em></strong></h3><p>Every human being has a soul which needs a richer experiences to enjoy life. At least my soul is one among them. No matter how much you miss your spouse or family during your travel, just by looking at the beautiful green nature, the blue waters and the high range mountains you feel a kind of sweetness in your soul. It seems as if your soul wants to <em>drink in</em> this entire experience. It seems as if you want a time machine which can stop this moment of time from passing by. You want this beautiful experience of yours to last forever in your brain. It makes you feel that you lived all this while to experience these beautiful things. So don’t feel bad if you don’t have your close ones, your soul is your best friend for your entire life. Cherish these beautiful memories and let your soul enjoy them.</p><h3><strong><em>Humanity exists everywhere</em></strong></h3><p>To relate to this, let me tell you a story. I went to after party reception at Edinburgh, UK. While coming back after the reception at 7 pm, I was surprised to see that the streets of UK were entirely dark with no human trace at all. I was scared and somehow hurried to my hotel. When I reached the hotel, I put my keys into the lock at the entrance door to open it. In most parts of UK, every user is given a unique PIN and a unique key. The user needs to open the hotel door and the room door using this key and PIN. I was new to this system and was trying hard to open the hotel door but couldn&#39;t. I tried for around 20 mins but somehow did not succeed in opening the door. I looked around and found an old man seated in his car parked nearby. I went to him and explained my trouble. He was kind enough to help me in opening the door. I cannot forget this experience and it taught me that no matter wherever you go, most people will be kind. I have experienced this at many places around the world. Humanity and kindness are inherent to human beings and these experiences have proven them.</p><h3><strong><em>A simple smile can win hearts</em></strong></h3><p>In most countries that I have traveled around the world, I have seen people smile at me. It’s a sign of friendly greeting in most countries. Some people also greet and say “Good Morning”. Some people also ask “How is your day?”. These are small gestures but one feels great when an unknown person asks about you or greets you while leaving to office. We are so bogged down by our own pressures of life, that we fail to smile at most times. Smiling though is a small gesture, it can win you friends at unknown places and make your life simpler. We often underestimate this small thing and it becomes important to remind ourselves to smile everyday. It releases endorphins which are vital to reduce stress and happy living.</p><h3><strong><em>You learn from your own mistakes</em></strong></h3><p>When you are travelling solo, I guess you make more mistakes than usual. You may fail to book a ticket to a museum or miss an important announcement at the airport. You learn from it and these mistakes become recorded into our subconscious brain. I am not saying that you must commit a mistake but my perception is that you will learn some very important lessons from your travel mistakes. The next time you travel, you subconsciously remember the old mistakes and try not to repeat them. It will guide you to a better travelling experience in future.</p><h3><strong><em>Boosts your confidence</em></strong></h3><p>You can observe most people who travel solo. One thing you can note about them from their face, is the <em>level of confidence</em>. Travelling solo requires a certain amount of confidence in yourself. That you would be able to handle your crazy self, be able to cook food if you cannot find good food and also manage your money to pay all the unexpected expenses that may arise. It forces you to become independent and trust yourself. Because until you start loving and trusting yourself, you will never be able to enjoy your solo travel.</p><h3><strong><em>You get lost but ultimately you find your way</em></strong></h3><p>If you hear stories of most people who travel solo, I am sure you will find 90% of the people get lost during travel. They would have missed a metro train or chosen a wrong bus or booked a wrong cab. The stories are endless but at the end they find their way back. A young man on the road would have told the right address or a women in the train would have directed to catch the right train at the next stop. I have also got lost at major cities. But instead of panicking, I asked help from people nearby. An old man helped me find a right train at Sydney and reach my destination. It teaches you an important life lesson that no matter where you are lost now in life, you need to find a way out. You need to seek help and enjoy the journey rather than worrying about the destination.</p><h3>You are no longer the person before travel</h3><p>After I return back from my travel, there are 2 things that happen to me. Firstly, I feel that I have learned something and my mind has experienced something worthwhile to last in my memories forever. I feel I have become a little wiser and humble. These experiences have made my life richer than what it was before travel. Second, I feel immensely astonishing how God would have created such a beautiful world. My head bows to Him in gratitude and I pray to Him to protect this precious ecosystem for the generations to come.</p><blockquote>“A mind that is stretched by a new experience can never go back to its old dimensions “— <strong>Oliver Wendell Holmes, Jr.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae0e92aef90a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-ascent/what-solo-traveling-teaches-you-ae0e92aef90a">What Solo Traveling Teaches You</a> was originally published in <a href="https://medium.com/the-ascent">Ascent Publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Power of Documenting Everyday]]></title>
            <link>https://medium.com/afwp/the-power-of-documenting-everyday-51f73337721?source=rss-23efc19f453------2</link>
            <guid isPermaLink="false">https://medium.com/p/51f73337721</guid>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[documentation]]></category>
            <dc:creator><![CDATA[Supriya Sirbi]]></dc:creator>
            <pubDate>Tue, 22 Oct 2019 03:12:24 GMT</pubDate>
            <atom:updated>2019-11-28T02:43:46.352Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How recording your day helps you to grow</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4x7x80Bo3h7Zj0Eb" /><figcaption>Photo by <a href="https://unsplash.com/@thoughtcatalog?utm_source=medium&amp;utm_medium=referral">Thought Catalog</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I have seen several people who love writing about their day. This includes the good things that they have done, things that they can do to improve themselves, mistakes they have committed and also about their day to day plans or tasks that needs to be executed. Also there are people who document their memories of a favorite trip or a hangout with friends. But a vast majority of people today think <em>Is Documentation really necessary?</em></p><p>Documentation refers to <em>recording something like an event or a process</em>. There are several ways in which documentation proves helpful. This post will guide you through the importance of documentation in our everyday lives.</p><ol><li><strong><em>Provides clarity</em></strong></li></ol><p>When we are faced with various problems in life, we are not clear on the approach needed to solve it. Also when we want to take a life changing major decision, we are not clear on the pros and cons of the decision. <strong><em>“A problem is half solved when its written”.</em></strong> Thus documenting your thoughts provides the much needed clarity which serves as a major step towards solving your problem.</p><p><strong><em>2. Redefine your life goals</em></strong></p><p>The problem with most youngsters today is that they are not clear on the goals that they want to achieve. People who don’t write down their goals tend to fail easier than the ones who have plans. Thus writing your goals helps you to plan better, redefine when needed and then refocus.</p><p><strong><em>3. Saves time and money</em></strong></p><p>Documenting your mistakes help you to learn from your past mistakes. Every human is bound to fail at times and commit mistakes that can be small or big in magnitude. As the saying goes, “<strong><em>Failures are the stepping stones to success</em></strong>” , these mistakes can help you grow and provide powerful life lessons. Thus keeping a note of your mistakes or failures prevents you from committing the same mistake again and helps to save time and money.</p><p><strong><em>4. Vent out your emotions</em></strong></p><p>Sometimes our emotions take control over us and we cannot help being sad, angry, happy or depressed. These are the times when writing a few lines explaining your anger or sadness can help you feel relieved after the write up is complete. In fact a lot of therapists suggest documenting as the best way to vent out your emotions. Since writing is a powerful tool for expression, a lot of people had better control of their emotions after a writing session. Also writing when you are happy for example after a vacation, makes you feel a lot more happier.</p><p><strong><em>5. Appreciate your life and stay positive</em></strong></p><p>Documenting your day helps you to appreciate the wonderful things in your life. There are so many people in this world who don’t have the right opportunities, don’t have money or have people to love them. It forces you to be grateful for the good things that you already have and stay positive.</p><p><strong><em>Record, Refuel and Refocus your life. Do you document everyday?</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/0*2wNmaDbT3Z7CsDRr.png" /></figure><h4>This story is published in <a href="https://medium.com/afwp?source=post_page---------------------------">a Few Words</a>, Medium’s publication that only accepts stories under 500 words.</h4><h4>If you have a few meaningful words to say and want to be a writer in our publication, visit <a href="https://medium.com/afwp/write-for-us-4c370c63348a">here</a>.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51f73337721" width="1" height="1" alt=""><hr><p><a href="https://medium.com/afwp/the-power-of-documenting-everyday-51f73337721">The Power of Documenting Everyday</a> was originally published in <a href="https://medium.com/afwp">a Few Words</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>