{"id":8799,"date":"2022-06-29T11:15:24","date_gmt":"2022-06-29T11:15:24","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=8799"},"modified":"2023-05-26T06:45:39","modified_gmt":"2023-05-26T06:45:39","slug":"priority-queue-using-linked-list","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/","title":{"rendered":"Priority Queue Using Linked List"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg\" alt=\"\" \/><\/p>\n<p>A priority queue is a data structure that stores elements with associated priorities. It allows efficient insertion and removal of elements based on their priority values. One way to implement a priority queue is by using a linked list.<\/p>\n<p>In a linked list-based implementation of a priority queue, each element is represented by a node that contains the actual data and a priority value. The nodes are linked together to form a linked list structure.<\/p>\n<p>A priority queue using linked list offers flexibility in terms of efficient insertion and deletion operations. However, it may require linear time complexity for operations like insertion and deletion since finding the appropriate position or the element with the highest priority may involve traversing the linked list.<\/p>\n<h2>Priority Queue<\/h2>\n<p>Priority queue is an abstract data type, It is a type of queue in which each element has a priority assigned to it. The priority of the element determines the order in which elements are removed from the priority queue. In the priority queue, all the elements are arranged either in ascending order or descending order.<\/p>\n<h3>Priority Queue Properties:<\/h3>\n<ul>\n<li>In the priority queue, every element has priority assigned to it.<\/li>\n<li>The element with highest priority first.<\/li>\n<li>If two elements are having the same priority then they are served according to their order in the queue.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656499578545-Image-02.png\" alt=\"\" \/><\/p>\n<h2>Linked List<\/h2>\n<p>Linked list is a linear data structure just like arrays. In the linked list the elements are not stored in contiguous locations, the elements are connected or linked using pointers. Each node stores the data and the address of the next node.<\/p>\n<ul>\n<li>Data: The Data which is stored at the particular address.<\/li>\n<li>Reference: The address of the next node of the linked list.<\/li>\n<\/ul>\n<h3>Linked List Representation<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308429001-Image-01%20%281%29.png\" alt=\"\" \/><\/p>\n<h3>Implementation using Linked List<\/h3>\n<p>The highest priority element will always be the head of the linked list. The list will be arranged in the descending order based on the priority of the elements due to which we can remove the highest priority element in O(1) time.<br \/>\nFor inserting an element we have to traverse the list and find the proper position to insert the element so that the sequence of the priority queue will be maintained.<\/p>\n<h3>Algorithm<\/h3>\n<ul>\n<li>Create a new node with data and priority.<\/li>\n<li>Check the priority with the head Node.<\/li>\n<li>If the head has lower priority, then connect the new node with the head and move the head pointer to the new node.<\/li>\n<li>Else traverse the priority queue and find the proper position of the new node.<\/li>\n<\/ul>\n<h4>Code Implementation<\/h4>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_8800 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_8800 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_8800 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_8800 .wpsm_nav-tabs > li.active > a, #tab_container_8800 .wpsm_nav-tabs > li.active > a:hover, #tab_container_8800 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_8800 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_8800 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_8800 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_8800 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_8800 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_8800 .wpsm_nav-tabs > li > a:hover , #tab_container_8800 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_8800 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_8800 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_8800 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_8800 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_8800 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_8800 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_8800 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_8800 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_8800 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_8800 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_8800 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_8800\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_8800\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_8800_1\" aria-controls=\"tabs_desc_8800_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_8800_2\" aria-controls=\"tabs_desc_8800_2\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>C++<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_8800_3\" aria-controls=\"tabs_desc_8800_3\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Java<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_8800_4\" aria-controls=\"tabs_desc_8800_4\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_8800\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_8800_1\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"c\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\ntypedef struct node {\r\n\tint data;\r\n\r\n\tint priority;\r\n\r\n\tstruct node* next;\r\n\r\n} Node;\r\n\r\nNode* newNode(int d, int p)\r\n{\r\n\tNode* temp = (Node*)malloc(sizeof(Node));\r\n\ttemp-&gt;data = d;\r\n\ttemp-&gt;priority = p;\r\n\ttemp-&gt;next = NULL;\r\n\r\n\treturn temp;\r\n}\r\n\r\nint peek(Node** head)\r\n{\r\n\treturn (*head)-&gt;data;\r\n}\r\n\r\nvoid pop(Node** head)\r\n{\r\n\tNode* temp = *head;\r\n\t(*head) = (*head)-&gt;next;\r\n\tfree(temp);\r\n}\r\n\r\nvoid push(Node** head, int d, int p)\r\n{\r\n\tNode* start = (*head);\r\n\r\n\tNode* temp = newNode(d, p);\r\n\r\n\tif ((*head)-&gt;priority &gt; p) {\r\n\r\n\t\ttemp-&gt;next = *head;\r\n\t\t(*head) = temp;\r\n\t}\r\n\telse {\r\n\r\n\t\twhile (start-&gt;next != NULL &amp;&amp;\r\n\t\t\tstart-&gt;next-&gt;priority &lt; p) {\r\n\t\t\tstart = start-&gt;next;\r\n\t\t}\r\n\r\n\t\ttemp-&gt;next = start-&gt;next;\r\n\t\tstart-&gt;next = temp;\r\n\t}\r\n}\r\n\r\nint isEmpty(Node** head)\r\n{\r\n\treturn (*head) == NULL;\r\n}\r\n\r\nint main()\r\n{\r\n\t\/\/ Create a Priority Queue\r\n\t\/\/ 70-&gt;40-&gt;50-&gt;60\r\n\tNode* pq = newNode(40, 1);\r\n\tpush(&amp;pq, 50, 2);\r\n\tpush(&amp;pq, 60, 3);\r\n\tpush(&amp;pq, 70, 0);\r\n\r\n\twhile (!isEmpty(&amp;pq)) {\r\n\t\tprintf(&quot;%d &quot;, peek(&amp;pq));\r\n\t\tpop(&amp;pq);\r\n\t}\r\n\r\n\treturn 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_8800_2\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"cpp\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\n#include &lt;bits\/stdc++.h&gt;\r\nusing namespace std;\r\n\r\n\/\/ Node\r\ntypedef struct node\r\n{\r\n\tint data;\r\n\r\n\tint priority;\r\n\r\n\tstruct node* next;\r\n\r\n} Node;\r\n\r\nNode* newNode(int d, int p)\r\n{\r\n\tNode* temp = (Node*)malloc(sizeof(Node));\r\n\ttemp-&gt;data = d;\r\n\ttemp-&gt;priority = p;\r\n\ttemp-&gt;next = NULL;\r\n\r\n\treturn temp;\r\n}\r\n\r\nint peek(Node** head)\r\n{\r\n\treturn (*head)-&gt;data;\r\n}\r\n\r\nvoid pop(Node** head)\r\n{\r\n\tNode* temp = *head;\r\n\t(*head) = (*head)-&gt;next;\r\n\tfree(temp);\r\n}\r\n\r\nvoid push(Node** head, int d, int p)\r\n{\r\n\tNode* start = (*head);\r\n\r\n\t\/\/ Create new Node\r\n\tNode* temp = newNode(d, p);\r\n\r\n\tif ((*head)-&gt;priority &gt; p)\r\n\t{\r\n\t\t\r\n\t\ttemp-&gt;next = *head;\r\n\t\t(*head) = temp;\r\n\t}\r\n\telse\r\n\t{\r\n\t\twhile (start-&gt;next != NULL &amp;&amp;\r\n\t\t\tstart-&gt;next-&gt;priority &lt; p)\r\n\t\t{\r\n\t\t\tstart = start-&gt;next;\r\n\t\t}\r\n\r\n\t\ttemp-&gt;next = start-&gt;next;\r\n\t\tstart-&gt;next = temp;\r\n\t}\r\n}\r\n\r\nint isEmpty(Node** head)\r\n{\r\n\treturn (*head) == NULL;\r\n}\r\n\r\nint main()\r\n{\r\n\t\r\n\t\/\/ Create a Priority Queue\r\n\t\/\/ 70-&gt;40-&gt;50-&gt;60\r\n\tNode* pq = newNode(40, 1);\r\n\tpush(&amp;pq, 50, 2);\r\n\tpush(&amp;pq, 60, 3);\r\n\tpush(&amp;pq, 70, 0);\r\n\r\n\twhile (!isEmpty(&amp;pq))\r\n\t{\r\n\t\tcout &lt;&lt; &quot; &quot; &lt;&lt; peek(&amp;pq);\r\n\t\tpop(&amp;pq);\r\n\t}\r\n\treturn 0;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_8800_3\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nimport java.util.* ;\r\n\r\nclass Solution\r\n{\r\n\t\r\nstatic class Node {\r\n\tint data;\r\n\t\r\n\tint priority;\r\n\t\r\n\tNode next;\r\n\t\r\n}\r\n\r\nstatic Node node = new Node();\r\n\t\r\nstatic Node newNode(int d, int p)\r\n{\r\n\tNode temp = new Node();\r\n\ttemp.data = d;\r\n\ttemp.priority = p;\r\n\ttemp.next = null;\r\n\t\r\n\treturn temp;\r\n}\r\n\t\r\nstatic int peek(Node head)\r\n{\r\n\treturn (head).data;\r\n}\r\n\t\r\nstatic Node pop(Node head)\r\n{\r\n\tNode temp = head;\r\n\t(head) = (head).next;\r\n\treturn head;\r\n}\r\n\t\r\nstatic Node push(Node head, int d, int p)\r\n{\r\n\tNode start = (head);\r\n\t\r\n\tNode temp = newNode(d, p);\r\n\t\r\n\tif ((head).priority &gt; p) {\r\n\t\r\n\t\ttemp.next = head;\r\n\t\t(head) = temp;\r\n\t}\r\n\telse {\r\n\t\r\n\t\twhile (start.next != null &amp;&amp;\r\n\t\t\tstart.next.priority &lt; p) {\r\n\t\t\tstart = start.next;\r\n\t\t}\r\n\t\r\n\t\ttemp.next = start.next;\r\n\t\tstart.next = temp;\r\n\t}\r\n\treturn head;\r\n}\r\n\t\r\nstatic int isEmpty(Node head)\r\n{\r\n\treturn ((head) == null)?1:0;\r\n}\r\n\t\r\npublic static void main(String args[])\r\n{\r\n\t\/\/ Create a Priority Queue\r\n\t\/\/ 70.40.50.60\r\n\tNode pq = newNode(4, 1);\r\n\tpq =push(pq, 5, 2);\r\n\tpq =push(pq, 6, 3);\r\n\tpq =push(pq, 7, 0);\r\n\t\r\n\twhile (isEmpty(pq)==0) {\r\n\t\tSystem.out.printf(&quot;%d &quot;, peek(pq));\r\n\t\tpq=pop(pq);\r\n\t}\r\n\t\r\n}\r\n}\r\n\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_8800_4\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"python\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nclass PriorityQueueNode:\r\n  \r\n  def __init__(self, value, pr):\r\n      \r\n    self.data = value\r\n    self.priority = pr\r\n    self.next = None\r\n  \r\nclass PriorityQueue:\r\n  \r\n  def __init__(self):\r\n    \r\n    self.front = None\r\n    \r\n  def isEmpty(self):\r\n    \r\n    return True if self.front == None else False\r\n  \r\n  def push(self, value, priority):\r\n    \r\n    if self.isEmpty() == True:\r\n      \r\n      self.front = PriorityQueueNode(value, priority)\r\n      return 1\r\n      \r\n    else:\r\n      \r\n      if self.front.priority > priority:\r\n        \r\n        newNode = PriorityQueueNode(value, priority)\r\n        \r\n        newNode.next = self.front\r\n        \r\n        self.front = newNode\r\n        \r\n        return 1\r\n        \r\n      else:\r\n        \r\n        temp = self.front\r\n        \r\n        while temp.next:\r\n          \r\n          if priority <= temp.next.priority:\r\n            break\r\n          \r\n          temp = temp.next\r\n        \r\n        newNode = PriorityQueueNode(value, priority)\r\n        newNode.next = temp.next\r\n        temp.next = newNode\r\n        \r\n        return 1\r\n  \r\n  def pop(self):\r\n    \r\n    if self.isEmpty() == True:\r\n      return\r\n    \r\n    else:\r\n      \r\n      self.front = self.front.next\r\n      return 1\r\n      \r\n  def peek(self):\r\n    \r\n    if self.isEmpty() == True:\r\n      return\r\n    else:\r\n      return self.front.data\r\n      \r\n  def traverse(self):\r\n    \r\n    if self.isEmpty() == True:\r\n      return \"Queue is Empty!\"\r\n    else:\r\n      temp = self.front\r\n      while temp:\r\n        print(temp.data, end = \" \")\r\n        temp = temp.next\r\n\r\nif __name__ == \"__main__\":\r\n  \r\n  pq = PriorityQueue()\r\n  pq.push(4, 1)\r\n  pq.push(5, 2)\r\n  pq.push(6, 3)\r\n  pq.push(7, 0)\r\n  \r\n  pq.traverse()\r\n  \r\n  pq.pop()\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_8800 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_8800 a\"),jQuery(\"#tab-content_8800\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Conclusion for priority queue with linked list<\/strong><br \/>\nIn conclusion, a linked list-based implementation of a priority queue provides a flexible approach to managing elements with associated priorities. It allows efficient insertion and removal operations based on the priority values. However, it may have linear time complexity for certain operations due to the need for traversing the linked list to find the appropriate position or the element with the highest priority.<\/p>\n<p>While there are more efficient data structures for larger priority queues, a linked list-based implementation can be suitable for smaller priority queues or situations that require dynamic resizing. It offers simplicity in terms of implementation and provides the ability to easily insert and remove elements in sorted order based on their priorities.<\/p>\n<p>Ultimately, the choice of a data structure for implementing a priority queue depends on the specific requirements of the application, such as the expected size of the priority queue, the frequency of operations, and the desired time complexity.<\/p>\n<h2>Frequently Asked Questions related to priority queue with linked list<\/h2>\n<p><strong>Q1. Can a linked list-based priority queue efficiently handle large priority queues?<\/strong><br \/>\n<strong>Ans.<\/strong> A linked list-based priority queue may not be the most efficient choice for large priority queues. The time complexity of operations like insertion and deletion in a linked list can be linear, requiring traversing the list to find the appropriate position or the element with the highest priority. Other data structures like binary heaps or binary search trees are more efficient for larger priority queues.<\/p>\n<p><strong>Q2. What is the advantage of using a linked list-based priority queue over other data structures?<\/strong><br \/>\n<strong>Ans.<\/strong> One advantage of a linked list-based priority queue is its flexibility. It allows for dynamic resizing and easy insertion and removal of elements. It can be a suitable choice for smaller priority queues or situations where elements need to be kept in a sorted order based on their priorities.<\/p>\n<p><strong>Q3. Does a linked list-based priority queue preserve the order of equal priority elements?<\/strong><br \/>\n<strong>Ans.<\/strong> In a linked list-based implementation, the order of equal priority elements is typically preserved. When inserting elements with the same priority, they are placed in the order of their arrival. The first element to be inserted among elements with the same priority will be positioned closer to the head of the linked list.<\/p>\n<p><strong>Q4. How can the efficiency of a linked list-based priority queue be improved?<\/strong><br \/>\n<strong>Ans.<\/strong> To improve the efficiency of a linked list-based priority queue, one approach is to use a doubly linked list. This allows for the efficient removal of elements by maintaining references to both the previous and next nodes. Another improvement can be achieved by keeping the linked list sorted based on priorities, which can speed up the insertion process. However, for significant efficiency gains, other data structures like binary heaps or binary search trees are generally preferred.<\/p>\n<p><strong>Q5. Can a linked list-based priority queue handle elements with dynamically changing priorities?<\/strong><br \/>\n<strong>Ans.<\/strong> Yes, a linked list-based priority queue can handle elements with dynamically changing priorities. If the priority of an element changes, it can be removed from its current position in the linked list and reinserted at the appropriate position based on the updated priority value.<\/p>\n<p><strong>Q6. Does a linked list-based priority queue support efficient searching for a specific element?<\/strong><br \/>\n<strong>Ans.<\/strong> A linked list-based implementation does not offer efficient searching for a specific element. To find a specific element, you would need to traverse the linked list and compare the element values. Other data structures like hash-based structures or binary search trees provide better search performance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A priority queue is a data structure that stores elements with associated priorities. It allows efficient insertion and removal of elements based on their priority values. One way to implement a priority queue is by using a linked list. In a linked list-based implementation of a priority queue, each element is represented by a node [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[125],"tags":[188,149],"class_list":["post-8799","post","type-post","status-publish","format-standard","hentry","category-linked-list","tag-linked-list","tag-queue"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Priority Queue Using Linked List | Queue | Prepbytes<\/title>\n<meta name=\"description\" content=\"Priority queue is an abstract data type in which each element has a priority assigned to it. In this article we&#039;ll learn how to implement Priority Queue Using linked list.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Priority Queue Using Linked List | Queue | Prepbytes\" \/>\n<meta property=\"og:description\" content=\"Priority queue is an abstract data type in which each element has a priority assigned to it. In this article we&#039;ll learn how to implement Priority Queue Using linked list.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-06-29T11:15:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-26T06:45:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Priority Queue Using Linked List\",\"datePublished\":\"2022-06-29T11:15:24+00:00\",\"dateModified\":\"2023-05-26T06:45:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/\"},\"wordCount\":1016,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg\",\"keywords\":[\"linked list\",\"queue\"],\"articleSection\":[\"Linked list articles\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/\",\"name\":\"Priority Queue Using Linked List | Queue | Prepbytes\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg\",\"datePublished\":\"2022-06-29T11:15:24+00:00\",\"dateModified\":\"2023-05-26T06:45:39+00:00\",\"description\":\"Priority queue is an abstract data type in which each element has a priority assigned to it. In this article we'll learn how to implement Priority Queue Using linked list.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linked list articles\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/linked-list\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Priority Queue Using Linked List\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Priority Queue Using Linked List | Queue | Prepbytes","description":"Priority queue is an abstract data type in which each element has a priority assigned to it. In this article we'll learn how to implement Priority Queue Using linked list.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/","og_locale":"en_US","og_type":"article","og_title":"Priority Queue Using Linked List | Queue | Prepbytes","og_description":"Priority queue is an abstract data type in which each element has a priority assigned to it. In this article we'll learn how to implement Priority Queue Using linked list.","og_url":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-06-29T11:15:24+00:00","article_modified_time":"2023-05-26T06:45:39+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Priority Queue Using Linked List","datePublished":"2022-06-29T11:15:24+00:00","dateModified":"2023-05-26T06:45:39+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/"},"wordCount":1016,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg","keywords":["linked list","queue"],"articleSection":["Linked list articles"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/","url":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/","name":"Priority Queue Using Linked List | Queue | Prepbytes","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg","datePublished":"2022-06-29T11:15:24+00:00","dateModified":"2023-05-26T06:45:39+00:00","description":"Priority queue is an abstract data type in which each element has a priority assigned to it. In this article we'll learn how to implement Priority Queue Using linked list.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1656308398347-Article.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/priority-queue-using-linked-list\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Linked list articles","item":"https:\/\/prepbytes.com\/blog\/category\/linked-list\/"},{"@type":"ListItem","position":3,"name":"Priority Queue Using Linked List"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/8799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=8799"}],"version-history":[{"count":4,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/8799\/revisions"}],"predecessor-version":[{"id":16544,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/8799\/revisions\/16544"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=8799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=8799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=8799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}