<?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 Amir Khan on Medium]]></title>
        <description><![CDATA[Stories by Amir Khan on Medium]]></description>
        <link>https://medium.com/@amir.khan_34135?source=rss-2b31aeed5921------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*G0RXkNv8EPx6JVOy</url>
            <title>Stories by Amir Khan on Medium</title>
            <link>https://medium.com/@amir.khan_34135?source=rss-2b31aeed5921------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:17:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@amir.khan_34135/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[Importance of DSA in Software Development]]></title>
            <link>https://medium.com/fasal-engineering/importance-of-dsa-in-software-development-dfe0fb6502f5?source=rss-2b31aeed5921------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfe0fb6502f5</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[data-structure-algorithm]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Amir Khan]]></dc:creator>
            <pubDate>Tue, 31 Jan 2023 10:37:51 GMT</pubDate>
            <atom:updated>2023-01-31T10:37:51.002Z</atom:updated>
            <content:encoded><![CDATA[<p>Data structures and algorithms are fundamental concepts in computer science and are used in various areas of software development. They provide a way to organise and manipulate data in an efficient and optimal manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*24LiyL--J77SYgMJyL-hhw.png" /><figcaption><a href="https://github.com/topics/hackerrank-datastructure">source</a></figcaption></figure><h3>DS + A</h3><p>Data structures are used to store and manage data in a specific format. Some common data structures include arrays, linked lists, stacks, queues, trees, and graphs. Each data structure has its own advantages and disadvantages and is suitable for different types of problems. For example, arrays are great for storing a large number of elements in a contiguous block of memory, whereas linked lists are useful when elements need to be inserted or deleted frequently.</p><p>Algorithms, on the other hand, are a set of instructions that specify how to solve a problem. They can be used to manipulate data stored in data structures, as well as perform other operations such as sorting, searching, and traversing. Some common algorithms include linear and binary search, quick sort and merge sort, and depth-first and breadth-first search.</p><h3>The Importance</h3><p>In software development, data structures and algorithms are used to implement various functionalities of a program. For example, in a web application, data structures such as arrays and linked lists may be used to store and manage information about users and their interactions with the application. Algorithms such as quick sort and linear search may be used to sort and search through this data. In a game, data structures such as stacks and queues may be used to implement features like undo and redo functionality, while algorithms such as pathfinding and collision detection may be used to control the movement of characters and objects in the game.</p><p>It is important to note that the choice of data structures and algorithms can have a significant impact on the performance and scalability of a program. Careful consideration should be given to which data structures and algorithms are best suited for a given problem, as well as how they will be implemented and optimised.</p><h3>Let’s take a look at few examples</h3><blockquote><strong><em>Problem</em></strong><em>:</em> Storing and retrieving a large number of customer records.</blockquote><p>Inefficient design:</p><pre>vector&lt;Customer&gt; customers;<br>void add_customer(Customer customer) {<br>    customers.push_back(customer);<br>}<br>Customer get_customer(int id) {<br>    for (auto customer : customers) {<br>        if (customer.id == id) {<br>            return customer;<br>        }<br>    }<br>    return Customer();<br>}</pre><p>In this example, we are using a simple vector to store the customer records and linear search through the vector to find a specific customer record. This will have a time complexity of O(n) for search operations, which can become slow for large data sets.</p><p>Efficient design:</p><pre>unordered_map&lt;int, Customer&gt; customers;<br>void add_customer(int id, Customer customer) {<br>    customers[id] = customer;<br>}<br>Customer get_customer(int id) {<br>    return customers[id];<br>}</pre><p>In this example, we are using an unordered_map to store the customer records. The key is the customer ID and the value is the customer record. Unordered_map i.e Hash map provides an average O(1) time complexity for insertion, deletion and search operations, making them efficient for large data sets.</p><blockquote><strong><em>Problem</em></strong><em>:</em> Implementing an undo/redo feature in a text editor.</blockquote><p>Inefficient design:</p><pre>vector&lt;string&gt; states;<br>int current_state = 0;<br>void save_state(string text) {<br>    states.resize(current_state + 1);<br>    states[current_state] = text;<br>    current_state++;<br>}<br>string undo() {<br>    if (current_state &gt; 0) {<br>        current_state - ;<br>        return states[current_state];<br>    }<br>    return &quot;&quot;;<br>}<br>string redo() {<br>    if(current_state &lt; states.size() - 1) {<br>        current_state++;<br>        return states[current_state];<br>    }<br>    return &quot;&quot;;<br>}</pre><p>This design is inefficient because it requires resizing the vector every time a new state is added, which can be slow if there are a large number of states. Additionally, the undo and redo operations have a time complexity of O(1) because the vector is implemented as a dynamic array and the elements are stored in contiguous memory. However, the insert and erase operations in vector are O(n) which can slow down the performance of the algorithm.</p><p>Efficient design:</p><pre>list&lt;string&gt; states;<br>list&lt;string&gt;::iterator current_state;<br>void save_state(string text) {<br>    states.erase(next(current_state), states.end());<br>    states.push_back(text);<br>    current_state = prev(states.end());<br>}<br>string undo() {<br>    if (current_state != states.begin()) {<br>        current_state - ;<br>        return *current_state;<br>    }<br>    return &quot;&quot;;<br>}<br>string redo() {<br>    if (current_state != prev(states.end())) {<br>        current_state++;<br>        return *current_state;<br>    }<br>    return &quot;&quot;;<br>}</pre><p>In this example, we are using a doubly-linked list ( can also be done using stack )to store the previous states of the text, where each node in the list represents a state. The undo operation can be performed by moving to the previous node in the list and redo operation by moving to the next node in the list. This will have a time complexity of O(1) for undo and redo operations.</p><h3>To summarize -</h3><p>Data structures and algorithms are essential components of software development, providing a way to organise and manipulate data in an efficient and optimal manner. They are used to implement various functionalities of a program and the choice of data structures and algorithms can have a significant impact on the performance and scalability of a program.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfe0fb6502f5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/fasal-engineering/importance-of-dsa-in-software-development-dfe0fb6502f5">Importance of DSA in Software Development</a> was originally published in <a href="https://medium.com/fasal-engineering">Fasal Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>