<?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: kenkomu</title>
    <description>The latest articles on DEV Community by kenkomu (@kenkomu).</description>
    <link>https://dev.to/kenkomu</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%2F880065%2F2b559bed-42da-4a84-b07a-27a8e2fa7318.png</url>
      <title>DEV Community: kenkomu</title>
      <link>https://dev.to/kenkomu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kenkomu"/>
    <language>en</language>
    <item>
      <title>DATA STRUCTURES AND ALGORITHMS</title>
      <dc:creator>kenkomu</dc:creator>
      <pubDate>Tue, 21 Jun 2022 07:16:17 +0000</pubDate>
      <link>https://dev.to/kenkomu/data-structures-and-algorithms-4g01</link>
      <guid>https://dev.to/kenkomu/data-structures-and-algorithms-4g01</guid>
      <description>&lt;p&gt;*&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;u&gt;WHAT IS DATA STRUCTURES&lt;/u&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Data Structures are the programmatic way of storing data so that data can be used efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;&lt;u&gt;WHAT IS ALGORITHMS&lt;/u&gt;&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;A finite sequence of instructions, each&lt;br&gt;
of which has a clear meaning and can be performed with a finite amount of effort in a finite length of time.&lt;/p&gt;
&lt;h2&gt;
  
  
  Applications of Data Structure and Algorithms
&lt;/h2&gt;

&lt;p&gt;From the data structure point of view, following are some important categories of algorithms −&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Search − Algorithm to search an item in a data structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sort − Algorithm to sort items in a certain order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Insert − Algorithm to insert item in a data structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Update − Algorithm to update an existing item in a data &lt;br&gt;
       structure.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Delete − Algorithm to delete an existing item from a data &lt;br&gt;
       structure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Characteristics of an Algorithm
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Unambiguous − Algorithm should be clear and unambiguous. &lt;br&gt;
Each of its steps (or phases), and their inputs/outputs &lt;br&gt;
should be clear and must lead to only one meaning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Input − An algorithm should have 0 or more well-defined &lt;br&gt;
inputs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Output − An algorithm should have 1 or more well-defined &lt;br&gt;
outputs, and should match the desired output.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finiteness − Algorithms must terminate after a finite &lt;br&gt;
number of steps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Feasibility − Should be feasible with the available &lt;br&gt;
resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Independent − An algorithm should have step-by-step &lt;br&gt;
directions, which should be independent of any programming &lt;br&gt;
code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An algorithm is said to be efficient and fast, if it takes less time to execute and consumes less memory space. The performance of an algorithm is measured on the basis of following properties :&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Time complexity&lt;/li&gt;
&lt;li&gt;Space complexity&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When we are analysing the complexity of any algorithm in terms of time and space,we can never provide an exact number to define the time required and the space required by the algorithm, instead we express it using some standard notations, also known as &lt;strong&gt;Asymptotic Notations&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Space Complexity of Algorithms&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Space complexity&lt;/strong&gt; is the amount of memory used by the algorithm (including the input values to the algorithm) to execute and produce the result.&lt;/p&gt;
&lt;h2&gt;
  
  
  Calculating the Space Complexity
&lt;/h2&gt;

&lt;p&gt;While calculating space complexity, we need to know the value of memory used by different types of datatypes variable.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Type&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Size&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;bool, char, unsigned char, signed char, __int8&lt;/td&gt;
&lt;td&gt;1 byte&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;__int16, short, unsigned short, wchar_t, __wchar_t&lt;/td&gt;
&lt;td&gt;2 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;float, __int32, int, unsigned int, long, unsigned long&lt;/td&gt;
&lt;td&gt;4 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;double, __int64, long double, long long&lt;/td&gt;
&lt;td&gt;8 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Example 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    int x = a + b ;
    return(x);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, variables x, a, and b are all integer types, which will take up 4 bytes each, so the total memory requirement will be (3(4) +4 = 20 bytes, this additional 4 bytes is for &lt;strong&gt;return value&lt;/strong&gt;. And because this space requirement is fixed for the above example, hence it is called Constant &lt;strong&gt;Space Complexity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// n is the length of array a[]
int division(int a[], int n)
{
    int x = 0;      // 4 bytes for x
    for(int i = 0; i &amp;lt; n; i++)  // 4 bytes for i
    {   
        x  = x / a[i];      
    }
    return(x);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In the above code, 4*n bytes of space is required for the array a[] elements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;4 bytes each for x, n, i and the return value.&lt;br&gt;
Hence the total memory requirement will be (4n + 12), which is increasing linearly with the increase in the input value n, hence it is called as &lt;strong&gt;Linear Space Complexity&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Time Complexity of Algorithms&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For any defined problem which must be solved using a program, there can be infinite number of solutions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time complexity of an algorithm&lt;/strong&gt; signifies the total time required by the program to run till its completion.&lt;/p&gt;

&lt;p&gt;The time complexity of algorithms is most commonly expressed using the big O notation. It's an asymptotic notation to represent the time complexity.&lt;br&gt;
since the algorithm's performance may vary with different types of input data, hence for an algorithm we usually use the &lt;strong&gt;worst-case Time complexity&lt;/strong&gt; of an algorithm because that is the maximum time taken for any input size.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>luxacademy</category>
      <category>python</category>
      <category>algorithms</category>
    </item>
  </channel>
</rss>
