<?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: Mahibul Haque</title>
    <description>The latest articles on DEV Community by Mahibul Haque (@mahibulhaque).</description>
    <link>https://dev.to/mahibulhaque</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%2F863664%2F963cd8d3-91dd-4b69-a40b-20540c73580a.png</url>
      <title>DEV Community: Mahibul Haque</title>
      <link>https://dev.to/mahibulhaque</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mahibulhaque"/>
    <language>en</language>
    <item>
      <title>An Intro to Heap Data Structure</title>
      <dc:creator>Mahibul Haque</dc:creator>
      <pubDate>Fri, 03 Jun 2022 14:12:11 +0000</pubDate>
      <link>https://dev.to/mahibulhaque/an-intro-to-heap-data-structure-hjp</link>
      <guid>https://dev.to/mahibulhaque/an-intro-to-heap-data-structure-hjp</guid>
      <description>&lt;h3&gt;
  
  
  Topics that is going to be discussed-
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Array Representation of BT&lt;/li&gt;
&lt;li&gt;Complete Binary Tree&lt;/li&gt;
&lt;li&gt;Heap&lt;/li&gt;
&lt;li&gt;Insert &amp;amp; Delete&lt;/li&gt;
&lt;li&gt;Heap Sort&lt;/li&gt;
&lt;li&gt;Heapify&lt;/li&gt;
&lt;li&gt;Priority Queue&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Array Representation of Binary Tree&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FOvueqCq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bed5h66a7glqt7bzttpz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FOvueqCq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bed5h66a7glqt7bzttpz.png" alt="Array Representation" width="294" height="292"&gt;&lt;/a&gt;&lt;br&gt;
If a Node is at index -&amp;gt; i&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's left child is at -&amp;gt; 2*i&lt;/li&gt;
&lt;li&gt;It's right child is at -&amp;gt; 2*i+1&lt;/li&gt;
&lt;li&gt;It's parent is at -&amp;gt; i/2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;If there are missing nodes in the Binary Tree, you need leave the corresponding index of the array blank&lt;/em&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Full Binary Tree V Complete Binary Tree&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gy3EZWYo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vwb8wc3ods32ji03sxdd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gy3EZWYo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vwb8wc3ods32ji03sxdd.jpg" alt="Full binary tree" width="320" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, the number of nodes of full binary tree is - (2^h+1)-1&lt;br&gt;
&lt;em&gt;Here, h is the height of the binary tree&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete Binary Tree&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--E5QYNmZw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmjsqfkr8fj5ukkksmy7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E5QYNmZw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pmjsqfkr8fj5ukkksmy7.jpg" alt="Complete binary tree" width="322" height="248"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a complete binary tree, if we traverse the binary tree in a level order fashion then we cannot have a missing node in between two nodes. So, a complete binary tree can be a full binary tree up until the binary tree's h-1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of a not Complete binary tree in array representation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OKOxSEHj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwg90iuvk8va42hdg25m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OKOxSEHj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwg90iuvk8va42hdg25m.png" alt="Array representation of not complete tree" width="600" height="75"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Height of a Complete Binary Tree will always be log(n)&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Heap&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Heap is a complete binary tree.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P1iV7G2R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7n74ytf4ygcjip7apqzh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P1iV7G2R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7n74ytf4ygcjip7apqzh.png" alt="Min heap vs max heap" width="312" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Min heap&lt;/strong&gt; - Min heap is a complete binary tree satisfying the condition that each node is having the element smaller or equal to all its descendants.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Max heap&lt;/strong&gt; - Min heap is a complete binary tree satisfying the condition that each node is having the element greater or equal to all its descendants.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time taken for a insertion in a Heap&lt;/strong&gt;-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;minimum: O(1)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;maximum: O(logn)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you delete from a &lt;code&gt;max-heap&lt;/code&gt; you will get the next largest element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you delete from a &lt;code&gt;min-heap&lt;/code&gt; you will get the next smallest element.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Heap Sort&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step-1: For a given set of elements create a heap.&lt;/li&gt;
&lt;li&gt;Step-2: Delete all the elements one by one.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hence, all the elements will be sorted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time Complexity for Heap Sort&lt;/strong&gt;: &lt;em&gt;O(nlogn)&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Heapify&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;While creating the heap in &lt;code&gt;step-1&lt;/code&gt; instead of going through the array from left to right, we go through it by going from right to left. You might wonder how this helps. If you recall heap element deletion procedure you will recall that the element that is to be deleted is sent to the bottom. We use that principle to build the heap in the &lt;code&gt;heapify&lt;/code&gt; procedure. If a element does not have a children we just create the heap but if an element does posses children than we compare the children with parent and adjust the elements accordingly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L7-aYXzZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3wvao1rwynj8pyb8h3h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L7-aYXzZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3wvao1rwynj8pyb8h3h.png" alt="Heapify" width="880" height="837"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Time complexity for Heapify is &lt;strong&gt;O(n)&lt;/strong&gt; which is better than the &lt;strong&gt;O(nlogn)&lt;/strong&gt; time complexity we get by following the create heap procedure.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Priority Queue&lt;/strong&gt;: In a priority queue elements should be deleted in the order of higher priority.&lt;/p&gt;

&lt;p&gt;1.There can be two kinds priority - smaller number -&amp;gt; higher priority or larger number -&amp;gt; higher priority.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;For smaller number -&amp;gt; higher priority you can use &lt;code&gt;min-heap&lt;/code&gt; and for larger number -&amp;gt; higher priority you can use &lt;code&gt;max-heap&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Since, insertion and deletion in a heap takes O(logn) time it is a great data structure for implementing priority queues.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>datastructure</category>
    </item>
    <item>
      <title>An Idea about Blockchain</title>
      <dc:creator>Mahibul Haque</dc:creator>
      <pubDate>Wed, 18 May 2022 13:59:46 +0000</pubDate>
      <link>https://dev.to/mahibulhaque/an-idea-about-blockchain-4m9</link>
      <guid>https://dev.to/mahibulhaque/an-idea-about-blockchain-4m9</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is Blockchain?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The generally accepted definition of a blockchain is a distributed ledger with smart contracts.&lt;br&gt;
In business, whenever any object of value or important changes, it is captured in a transaction. Transactions therefore describe how a company's essential assets move through a lifecycle; for example, their movement between their suppliers and  consumers in a supply chain.&lt;br&gt;
Traditionally, transactions are recorded in a business ledger. Unfortunately, a transaction which involves multiple organizations will be recorded differently by each business. Business processes which would benefit from a consistent, up-to-date and high integrity ledger are adversely affected organizations with different ledgers and technology recording essentially the same transactions. For example, if two organizations disagree on the state of a transaction then a dispute occurs, which can often be costly and time-consuming to resolve. A shared ledger can also introduce new possibilities; real-time tracking and tracing of products becomes possible when all the participants in a supply chain have access to a trusted source of transactions.Blockchain transactions and ledgers are different. Blockchain introduces a new kind of transaction – a multiparty transaction - that is signed by everyone involved in the transaction. Blockchain ledgers are different too; the same ledger is replicated in every organization in the network, and kept synchronized using a process called consensus. Moreover, these ledgers are immutable and final; once a multi-party transaction is written to the ledger, it cannot be reversed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Smart contracts
&lt;/h3&gt;

&lt;p&gt;In business, transactions are generated according to contracts which define the exact conditions under which a transaction is generated. If I buy a car from you and it breaks down a month later, the terms of our contract might say that you are liable for the repair.&lt;/p&gt;

&lt;p&gt;Blockchain introduces the idea of a smart contract. It describes in code what a transaction generated by the smart contract looks like. For example, a car contract might use logic to check that you're the current owner of the car, and that a purchaser has the required funds. If so, then a transaction will be generated that represents the transfer of the money to the seller and the car ownership to the buyer. &lt;/p&gt;

&lt;p&gt;Blockchains such as Hyperledger Fabric make it easy to write smart contracts, by maintaining the current value of every business object in a ledger. It means that smart contracts don't need to compute the cumulative effect of the history of transactions that involve your car -- they simply look up the current state of that car, and modify it as required. Hyperledger Fabric makes it easy to capture these object changes as transactions and recorded on the distributed blockchain ledger.&lt;/p&gt;

&lt;h3&gt;
  
  
  Blockchain and Bitcoin
&lt;/h3&gt;

&lt;p&gt;Blockchain is commonly associated with Bitcoin, the cryptocurrency and peer-to-peer payments system. Bitcoin uses a blockchain as the ledger to record its transactions and a resource-intensive method of consensus called proof of work. Bitcoin favors anonymity; even though the ledger is public, it's almost impossible to determine who is behind a Bitcoin transaction.&lt;/p&gt;

&lt;p&gt;Businesses often have a different operating environment. For example, they are required to carry out Know Your Customer (KYC) and Anti-Money Laundering (AML) checks, which require businesses to know who they are dealing with. This means that business blockchains require identifiable participants and favor features such as privacy and confidentiality. Knowing who's behind a transaction helps to remove incentives for fraud and as such, resource-intensive methods of consensus are not needed.&lt;/p&gt;

&lt;p&gt;And of course, business ledgers also store more than cryptocurrency transactions; any object of value to a business could be subject to multi-party transactions, and will therefore also benefit from a business blockchain.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What GraphQL Is and Isn't?</title>
      <dc:creator>Mahibul Haque</dc:creator>
      <pubDate>Tue, 17 May 2022 09:44:11 +0000</pubDate>
      <link>https://dev.to/mahibulhaque/what-graphql-is-and-isnt-2755</link>
      <guid>https://dev.to/mahibulhaque/what-graphql-is-and-isnt-2755</guid>
      <description>&lt;h3&gt;
  
  
  Definition :
&lt;/h3&gt;

&lt;p&gt;Graphql is a query language. But it does not mean it is a language that interacts with the database like popular SQL languages (e.g. MySQL, PostgresSQL).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;So what does GraphQL do?&lt;/strong&gt;&lt;br&gt;
 &lt;em&gt;Queries an API, not a database.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Distinction between Query and Mutation in GraphQL
&lt;/h3&gt;

&lt;p&gt;GraphQL doesn't require http requests method such as &lt;code&gt;GET&lt;/code&gt;, &lt;code&gt;POST&lt;/code&gt;, &lt;code&gt;PUT&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In GraphQL your most likely going to &lt;code&gt;GET&lt;/code&gt; data by using &lt;code&gt;Query&lt;/code&gt;. The other data update methods &lt;code&gt;POST, PUT, DELETE&lt;/code&gt; will be handled by &lt;code&gt;Mutations&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;query&lt;/code&gt; to fetch all the pets from the app might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;query GetAllPets {
  pets {
    name
    petType
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then a &lt;code&gt;mutation&lt;/code&gt; that adds a new pet might look a little something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mutation AddNewPet ($name: String!, $petType: PetType) {
  addPet(name: $name, petType: $petType) {
    id
    name
    petType
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  GraphQL Vs REST
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th&gt;GraphQL&lt;/th&gt;
&lt;th&gt;REST&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphQL is an application layer server-side technology which is developed by Facebook for executing queries with existing data.&lt;/td&gt;
&lt;td&gt;REST is a software architectural style that defines a set of constraints for creating Web services.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It follows client-driven architecture.&lt;/td&gt;
&lt;td&gt;It follows server-driven architecture.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphQL can be organized in terms of a schema.&lt;/td&gt;
&lt;td&gt;REST can be arranged in terms of endpoints.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphQL is a growing community.&lt;/td&gt;
&lt;td&gt;REST is a large community.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The development speed in GraphQL is fast.&lt;/td&gt;
&lt;td&gt;The development speed in REST is Slow.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The learning curve in GraphQL is difficult.&lt;/td&gt;
&lt;td&gt;The learning curve in REST is moderate.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The identity is separated from how you fetch it.&lt;/td&gt;
&lt;td&gt;The endpoint you call in REST is the identity of an object.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;In GraphQL, the server determines available resources.&lt;/td&gt;
&lt;td&gt;The shape and size of the resource are determined by the server in REST.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphQL provides high consistency across all platforms.&lt;/td&gt;
&lt;td&gt;It is hard to get consistency across all platforms.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The message format for GraphQL mutations should be a string.&lt;/td&gt;
&lt;td&gt;The message format for REST mutations can be anything.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It is strongly typed.&lt;/td&gt;
&lt;td&gt;It is weakly typed.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphQL API endpoints are single.&lt;/td&gt;
&lt;td&gt;REST API endpoints are multiple.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;It uses metadata for&lt;br&gt;
query validation.&lt;/td&gt;
&lt;td&gt;It does not have machine-readable metadata cacheable.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Provides consistent and high-quality UX across all operating systems.&lt;/td&gt;
&lt;td&gt;It is difficult to get consistency across all operating systems.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Partners of GraphQL require API customization.&lt;/td&gt;
&lt;td&gt;It offers flexible public API that can easily enable new applications.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
      <category>graphql</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
