<?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: 221910304004</title>
    <description>The latest articles on DEV Community by 221910304004 (@221910304004).</description>
    <link>https://dev.to/221910304004</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%2F626349%2F24c2861e-d3a0-40a8-b2d5-ac26e7399c5b.png</url>
      <title>DEV Community: 221910304004</title>
      <link>https://dev.to/221910304004</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/221910304004"/>
    <language>en</language>
    <item>
      <title>What is the Python priority queue?</title>
      <dc:creator>221910304004</dc:creator>
      <pubDate>Mon, 18 Oct 2021 05:53:24 +0000</pubDate>
      <link>https://dev.to/221910304004/what-is-the-python-priority-queue-4jdd</link>
      <guid>https://dev.to/221910304004/what-is-the-python-priority-queue-4jdd</guid>
      <description>&lt;p&gt;The priority queue is an advanced type of the queue data structure. Instead of dequeuing the oldest element, a priority queue sorts and dequeues elements based on their priorities.&lt;/p&gt;

&lt;p&gt;Priority queues are used to handle scheduling problems where some tasks are prioritized over others.&lt;/p&gt;

&lt;p&gt;The queue.PriorityQueue Class&lt;br&gt;
Python provides a built-in implementation of the priority queue data structure.&lt;/p&gt;

&lt;p&gt;Since the queue.PriorityQueue class needs to maintain the order of its elements, a sorting mechanism is required every time a new element is enqueued.&lt;/p&gt;

&lt;p&gt;Python solves this by using a binary heap to implement the priority queue.&lt;/p&gt;

&lt;p&gt;The Python priority queue is built on the heapq module, which is basically a binary heap.&lt;/p&gt;

&lt;p&gt;For insertion, the priority queue uses the put function in the following way:&lt;br&gt;
  pQueue.put(value)&lt;/p&gt;

&lt;p&gt;The get command dequeues the highest priority elements from the queue.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YAOJE1WY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wzcbe0ikrtlrz285apl0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YAOJE1WY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wzcbe0ikrtlrz285apl0.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Priority-object pairs can also be inserted into the queue. This way every task can be associated with a priority.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gh2Y2n_W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3ro0yllm6u47ji1dkbn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gh2Y2n_W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3ro0yllm6u47ji1dkbn.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Time Complexity&lt;/p&gt;

&lt;p&gt;Operation:                        Work-case Time complexity:&lt;br&gt;
Insertion                         O(logn)&lt;br&gt;
Deletion                          O(logn)&lt;/p&gt;

</description>
      <category>python</category>
      <category>priorityqueue</category>
      <category>datastructure</category>
      <category>heap</category>
    </item>
    <item>
      <title>How to solve Graph Coloring problem using Backtracking</title>
      <dc:creator>221910304004</dc:creator>
      <pubDate>Thu, 06 May 2021 04:59:55 +0000</pubDate>
      <link>https://dev.to/221910304004/how-to-solve-graph-coloring-problem-using-backtracking-3b4e</link>
      <guid>https://dev.to/221910304004/how-to-solve-graph-coloring-problem-using-backtracking-3b4e</guid>
      <description>&lt;p&gt;What is Backtracking ?&lt;/p&gt;

&lt;p&gt;Backtracking is nothing but its a technique based on algorithms. It uses recursion to find the solution step by step increasing values with time and also it removes the solutions which don’t rise the solution based on constraints given in problem.&lt;/p&gt;

&lt;p&gt;This backtracking is used in depth first search,graph coloring, Hamiltonian cycle.&lt;/p&gt;

&lt;p&gt;What is graph coloring?&lt;/p&gt;

&lt;p&gt;In graph coloring problem we color the vertices of graph in such a way that no two adjacent vertices or neighboring vertices share the same color. Same vertices can be colored in different ways so there are more one solutions possible here we want all possible solution what are the ways that can be colored so its like a permutations or trying out all possibilities and then picking up the one which are satisfying the condition, so the condition is neighboring vertices should not have same color so this type of problem can be solved using Backtracking then if you want multiple solutions and there is a different possible solution go for backtracking.&lt;/p&gt;

&lt;p&gt;In this problem we have given a chromatic number m which is the least number of colors needed to color a graph.&lt;/p&gt;

&lt;p&gt;EXAMPLE:&lt;/p&gt;

&lt;p&gt;Now we take a simple graph and show you how this can be solved by using backtracking&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1B7iUC6k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvdxvetsoo5ns3rrutas.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1B7iUC6k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bvdxvetsoo5ns3rrutas.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;STATE SPACE TREE:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aSxh-4B4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4npe3bedpk5z0wtu936.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aSxh-4B4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4npe3bedpk5z0wtu936.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;EXPLANATION:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;State space is tree is mainly used to find out all possible solutions of the graph which satisfies constraints.&lt;/li&gt;
&lt;li&gt;Initially A has the possible cases 1,2 and 3 if A takes the color 1 then B has two cases, and adjacent is 1 remaining two colors are 2 and 3 .Similarly this procedure is followed for vertices 2 and 3.&lt;/li&gt;
&lt;li&gt;Suppose B is colored with 2 then C has two cases either 1 and 3&lt;/li&gt;
&lt;li&gt;Now for D, A is 1 and C is 1 so possible combinations are 2 and 3.&lt;/li&gt;
&lt;li&gt;For example in the above tree C is 3 ,A is 1, B is 2 so the adjacent are 1 and 3 only possible case is 2.&lt;/li&gt;
&lt;li&gt;In the 3rd level A is 1 ,B is 3 and only adjacent is B,B is called 3 so the only possibility are 1 and 2. SO, C color is 1 and A color is 1 so two cases are 2 and 3. And A color is 1, B color is 3 and C color is 2 so, A and c are adjacent vertices, A color is 1, C color is 2 so remaining color is 3.&lt;/li&gt;
&lt;li&gt;Second level represents all the possible colors which can be placed in vertex A.&lt;/li&gt;
&lt;li&gt;Third level represents all the possible colors which can be placed in vertex B.&lt;/li&gt;
&lt;li&gt;Fourth level represents all the possible colors which can be placed in vertex C.&lt;/li&gt;
&lt;li&gt;Fifth level represents all the possible colors which can be placed in vertex D.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The chromatic number of the graph is 3(the minimum number of colors required to satisfy this problem).&lt;/p&gt;

</description>
      <category>graphcoloring</category>
      <category>backtracking</category>
    </item>
  </channel>
</rss>
