<?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: Hussam Elmaghraby</title>
    <description>The latest articles on DEV Community by Hussam Elmaghraby (@hussamelmaghraby).</description>
    <link>https://dev.to/hussamelmaghraby</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%2F786627%2F1515203e-f937-4f43-8d94-d5760ad1ee17.jpg</url>
      <title>DEV Community: Hussam Elmaghraby</title>
      <link>https://dev.to/hussamelmaghraby</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hussamelmaghraby"/>
    <language>en</language>
    <item>
      <title>Data Structures in Dart - #1 -Complexity</title>
      <dc:creator>Hussam Elmaghraby</dc:creator>
      <pubDate>Fri, 29 Sep 2023 01:47:02 +0000</pubDate>
      <link>https://dev.to/hussamelmaghraby/data-structure-in-dart-arrays-4mk3</link>
      <guid>https://dev.to/hussamelmaghraby/data-structure-in-dart-arrays-4mk3</guid>
      <description>&lt;p&gt;In this series of blogs, we will talk about the data structure in Dart.&lt;br&gt;
So let's know what a data structure is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data structures&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A data structure is a way to store and organize data in order to facilitate access and modification. Using the appropriate data structure or structures is an important part of algorithm design. No single data structure works well for all purposes, and so you should know the strengths.&lt;br&gt;
and the limitations of several of them.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Firstly, before we dive into data structure, we need to know what _complexity _is.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Complexity refers to the amount of time, space, and other resources required to solve a problem or execute an algorithm.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Complexity&lt;/strong&gt; is characterizing the efficiency of algorithms. Efficiency can be measured by&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Space Complexity&lt;/em&gt; -&amp;gt; Related to data structures and how information is stored&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Time Complexity&lt;/em&gt; -&amp;gt; Related to how fast the algorithm can process data and provide results&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Time Complexities Cases&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EAmjGPVE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pm2fj7ac0o1j1qj1rrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EAmjGPVE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1pm2fj7ac0o1j1qj1rrx.png" alt="Time Complexities Cases" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Constant Time&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It takes the same time regardless of the number of inputs.
For example:&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Xh5058XR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oq2dwaf9rr4ghh75ez03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xh5058XR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oq2dwaf9rr4ghh75ez03.png" alt="Constant Time Example 1" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AtJwijb1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uwtlfh1jjm1c0apqw0ab.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AtJwijb1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uwtlfh1jjm1c0apqw0ab.png" alt="Constant Time Example 2" width="800" height="335"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;_Note : As input data increases, the amount of time the algorithm takes does not change. The Big O notation for constant time is O(1).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--phg0olH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v56juk0ndxdy5nsos1xs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--phg0olH1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v56juk0ndxdy5nsos1xs.png" alt="Constant Time" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;: &lt;br&gt;
The Big O Notation is a metric for determining an algorithm's efficiency. Put simply, it gives an estimate of how long it takes your code to run on different sets of inputs. You can also see it as a way to measure how effectively your code scales as your input size increases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CIufgqdv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4ekd3m4whhyh4thx1ox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CIufgqdv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4ekd3m4whhyh4thx1ox.png" alt="Big O analysis" width="800" height="257"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Linear Time&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--W3fRuzvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ix8rkmhpz6h139nx9hs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--W3fRuzvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ix8rkmhpz6h139nx9hs3.png" alt="Linear Time Example" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XnyV2zon--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/44u5k3neezmj8sx6zuun.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XnyV2zon--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/44u5k3neezmj8sx6zuun.png" alt="Linear Time" width="452" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, as the amount of data increases, the running time increases by the same value.&lt;/p&gt;

&lt;p&gt;The Big O notation for this type of complexity is o(n).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Quadratic Time&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This type of algorithm takes time proportional to the square of the size of the inputs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FxSMyRlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yo7dhpf7enqdyjlhlwe7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FxSMyRlr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yo7dhpf7enqdyjlhlwe7.png" alt="Quadratic Time Example" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see in the graph below, as the input size increases, the time it takes to run this code increases drastically.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q_Xbuqh_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c3xdoii6dj9b2vkqaer.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q_Xbuqh_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c3xdoii6dj9b2vkqaer.png" alt="Quadratic Time" width="452" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Big O notation for this type is O(n)^2.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;At this point, you now know the concept of complexity and how to calculate the algorithm's efficiency.&lt;/p&gt;

&lt;p&gt;In this article, I just talk about three types of complexity. If you want to know about the rest of the complexity types, you can find many resources on the internet.&lt;/p&gt;

&lt;p&gt;I'm excited to see you in the next article.&lt;/p&gt;

&lt;p&gt;See you soon!&lt;/p&gt;

</description>
      <category>dart</category>
      <category>datastructures</category>
      <category>programming</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
