<?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: MoeHdaib</title>
    <description>The latest articles on DEV Community by MoeHdaib (@moehdaib).</description>
    <link>https://dev.to/moehdaib</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%2F480946%2Ff5f46979-c91f-4191-9967-773d9040b327.png</url>
      <title>DEV Community: MoeHdaib</title>
      <link>https://dev.to/moehdaib</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/moehdaib"/>
    <language>en</language>
    <item>
      <title>Hash table efficiency example</title>
      <dc:creator>MoeHdaib</dc:creator>
      <pubDate>Sat, 03 Oct 2020 13:04:12 +0000</pubDate>
      <link>https://dev.to/moehdaib/hash-table-efficiency-example-153g</link>
      <guid>https://dev.to/moehdaib/hash-table-efficiency-example-153g</guid>
      <description>&lt;p&gt;Hash tables is a data structure that can map keys to values which means that it gives every item in a list has key that is used to extract it later.&lt;br&gt;
Its known that hash tables has better performance than normal list but how its differ? &lt;/p&gt;

&lt;p&gt;I wrote a code to compare the time it gets for a list to extract an item in reletively big data structure as well as in a hash table.&lt;/p&gt;

&lt;p&gt;First, we fill the list and the hash table with &lt;strong&gt;5000000&lt;/strong&gt; values.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--swqCgLOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2a9xxwej5jgggya9q7gw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--swqCgLOi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/2a9xxwej5jgggya9q7gw.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we pick a reandom value between &lt;strong&gt;4 million&lt;/strong&gt; and &lt;strong&gt;5 million&lt;/strong&gt; to get the worst case. After that, we calculate the time it takes for the list and the hash table to extract the value. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MCC869j---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6nrbgushl6ky2qh4b49a.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MCC869j---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6nrbgushl6ky2qh4b49a.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After we execute the code the results are: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xaX8dMsN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i6cim57h8z76fsnxs9fb.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xaX8dMsN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i6cim57h8z76fsnxs9fb.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see the difference between the time. The hash table in all the tests took &lt;strong&gt;0&lt;/strong&gt; ms but the list took between &lt;strong&gt;34&lt;/strong&gt; to &lt;strong&gt;42&lt;/strong&gt; ms to extract the desired values.&lt;/p&gt;

&lt;p&gt;If you want test the code yourself check my &lt;a href="https://github.com/MoeHdaib/HashTime/blob/gh-pages/Code"&gt;GitHub&lt;/a&gt; &lt;/p&gt;

</description>
      <category>csharp</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
