{"id":9900,"date":"2022-09-25T23:26:45","date_gmt":"2022-09-25T23:26:45","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=9900"},"modified":"2022-10-10T08:33:52","modified_gmt":"2022-10-10T08:33:52","slug":"data-structures-using-c-queue-heap-2","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/","title":{"rendered":"Data Structures Using C | Queue | Heap"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg\" alt=\"\" \/><\/p>\n<\/p>\n<p>A data structure is not only used for organizing the data. It is also used for processing, retrieving, and storing data. There are different basic and advanced types of data structures that are used in almost every program or software system that has been developed. So we must have good knowledge about data structures. <\/p>\n<p>Data Structures using C is an important part of Programming. Get a better understanding of problems by watching these <a href=\"https:\/\/www.prepbytes.com\/preparation-videos\/data-structures-and-algorithms\" title=\"video tutorials\">video tutorials<\/a> created by expert mentors at <a href=\"https:\/\/www.prepbytes.com\/\" title=\"PrepBytes\">PrepBytes<\/a>.<\/p>\n<h3>Why Learn Data Structure?<\/h3>\n<p>Data structure and algorithms are two of the most important aspects of computer science. Data structures allow us to organize and store data, while algorithms allow us to process that data in a meaningful way. Learning data structure and algorithms will help you become a better programmer. You will be able to write code that is more efficient and more reliable. You will also be able to solve problems more quickly and more effectively.<\/p>\n<h3>Queue:<\/h3>\n<p>A queue can be defined as an ordered list which enables insert operations to be performed at one end called <strong>REAR<\/strong> and delete operations to be performed at another end called <strong>FRONT<\/strong>. Queue is referred to as First In First Out list.<br \/>\nFor example, people waiting in line for a rail ticket form a queue.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663911605321-1-01.png\" alt=\"\" \/><\/p>\n<h3>Operations performed on queue<\/h3>\n<p>The fundamental operations that can be performed on queue are listed as follows &#8211;<\/p>\n<ul>\n<li><strong>Enqueue<\/strong>: The Enqueue operation is used to insert the element at the rear end of the queue. It returns void.<\/li>\n<li><strong>Dequeue<\/strong>: It performs the deletion from the front-end of the queue. It also returns the element which has been removed from the front-end. It returns an integer value.<\/li>\n<li><strong>Peek<\/strong>: This is the third operation that returns the element, which is pointed by the front pointer in the queue but does not delete it.<\/li>\n<li><strong>Queue overflow (isfull)<\/strong>: It shows the overflow condition when the queue is completely full.<\/li>\n<li><strong>Queue underflow (isempty)<\/strong>: It shows the underflow condition when the Queue is empty, i.e., no elements are in the Queue.<\/li>\n<\/ul>\n<h3>Working of Queue<\/h3>\n<p>Queue operations work as follows:<\/p>\n<ul>\n<li>two pointers FRONT and REAR<\/li>\n<li>FRONT track the first element of the queue<\/li>\n<li>REAR track the last element of the queue<\/li>\n<li>initially, set value of FRONT and REAR to -1<\/li>\n<\/ul>\n<h3>Enqueue Operation<\/h3>\n<ul>\n<li>check if the queue is full<\/li>\n<li>for the first element, set the value of FRONT to 0<\/li>\n<li>increase the REAR index by 1<\/li>\n<li>add the new element in the position pointed to by REAR<\/li>\n<\/ul>\n<h3>Dequeue Operation<\/h3>\n<ul>\n<li>check if the queue is empty<\/li>\n<li>return the value pointed by FRONT<\/li>\n<li>increase the FRONT index by 1<\/li>\n<li>for the last element, reset the values of FRONT and REAR to -1<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663911692540-1-02.png\" alt=\"\" \/><\/p>\n<h3>Applications of Queue<\/h3>\n<p>Due to the fact that queue performs actions on a first in first out basis which is quite fair for the ordering of actions. There are various applications of queues discussed below.<\/p>\n<ol>\n<li>Queues are widely used as waiting lists for a single shared resource like printer, disk, CPU.<\/li>\n<li>Queues are used in asynchronous transfer of data (where data is not being transferred at the same rate between two processes) for eg. pipes, file IO, sockets.<\/li>\n<li>Queues are used as buffers in most of the applications like MP3 media player, CD player, etc.<\/li>\n<li>Queues are used to maintain the playlist in media players in order to add and remove the songs from the play-list.<\/li>\n<li>Queues are used in operating systems for handling interrupts.<\/li>\n<\/ol>\n<h3>Implementation:<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_9896 {\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_9896 .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_9896 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_9896 .wpsm_nav-tabs > li.active > a, #tab_container_9896 .wpsm_nav-tabs > li.active > a:hover, #tab_container_9896 .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_9896 .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_9896 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_9896 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_9896 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_9896 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_9896 .wpsm_nav-tabs > li > a:hover , #tab_container_9896 .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_9896 .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_9896 .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_9896 .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_9896 .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_9896 .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_9896 .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_9896 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9896 .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_9896 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9896 .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_9896 .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_9896\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_9896\">\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_9896_1\" aria-controls=\"tabs_desc_9896_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\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_9896\">\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_9896_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;string.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#include &lt;stdbool.h&gt;\r\n#define MAX 6\r\n\r\nint intArray[MAX];\r\nint front = 0;\r\nint rear = -1;\r\nint itemCount = 0;\r\n\r\nint peek(){\r\n   return intArray[front];\r\n}\r\nbool isEmpty(){\r\n   return itemCount == 0;\r\n}\r\nbool isFull(){\r\n   return itemCount == MAX;\r\n}\r\nint size(){\r\n   return itemCount;\r\n}\r\nvoid insert(int data){\r\n   if(!isFull()){\r\n      if(rear == MAX-1){\r\n         rear = -1;            \r\n      }       \r\n      intArray[++rear] = data;\r\n      itemCount++;\r\n   }\r\n}\r\nint removeData(){\r\n   int data = intArray[front++];\r\n   if(front == MAX){\r\n      front = 0;\r\n   }\r\n   itemCount--;\r\n   return data;  \r\n}\r\nint main() {\r\n   \/* insert 5 items *\/\r\n   insert(3);\r\n   insert(5);\r\n   insert(9);\r\n   insert(1);\r\n   insert(12);\r\n\r\n   \/\/ front : 0\r\n   \/\/ rear  : 4\r\n   \/\/ ------------------\r\n   \/\/ index : 0 1 2 3 4 \r\n   \/\/ ------------------\r\n   \/\/ queue : 3 5 9 1 12\r\n   insert(15);\r\n\r\n   \/\/ front : 0\r\n   \/\/ rear  : 5\r\n   \/\/ ---------------------\r\n   \/\/ index : 0 1 2 3 4  5 \r\n   \/\/ ---------------------\r\n   \/\/ queue : 3 5 9 1 12 15\r\n   if(isFull()){\r\n      printf(&quot;Queue is full!&#92;n&quot;);   \r\n   }\r\n\r\n   \/\/ remove one item \r\n   int num = removeData();\r\n   printf(&quot;Element removed: %d&#92;n&quot;,num);\r\n   \/\/ front : 1\r\n   \/\/ rear  : 5\r\n   \/\/ -------------------\r\n   \/\/ index : 1 2 3 4  5\r\n   \/\/ -------------------\r\n   \/\/ queue : 5 9 1 12 15\r\n\r\n   \/\/ insert more items\r\n   insert(16);\r\n\r\n   \/\/ front : 1\r\n   \/\/ rear  : -1\r\n   \/\/ ----------------------\r\n   \/\/ index : 0  1 2 3 4  5\r\n   \/\/ ----------------------\r\n   \/\/ queue : 16 5 9 1 12 15\r\n\r\n   \/\/ As queue is full, elements will not be inserted. \r\n   insert(17);\r\n   insert(18);\r\n\r\n   \/\/ ----------------------\r\n   \/\/ index : 0  1 2 3 4  5\r\n   \/\/ ----------------------\r\n   \/\/ queue : 16 5 9 1 12 15\r\n   printf(&quot;Element at front: %d&#92;n&quot;,peek());\r\n\r\n   printf(&quot;----------------------&#92;n&quot;);\r\n   printf(&quot;index : 5 4 3 2  1  0&#92;n&quot;);\r\n   printf(&quot;----------------------&#92;n&quot;);\r\n   printf(&quot;Queue:  &quot;);\r\n   while(!isEmpty()){\r\n      int n = removeData();           \r\n      printf(&quot;%d &quot;,n);\r\n   }   \r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_9896 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_9896 a\"),jQuery(\"#tab-content_9896\"));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<h3>Heap:<\/h3>\n<p>Heap represents a special tree based data structure used to represent priority queue or for heap sort. We&#8217;re going to discuss binary heap trees specifically.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663911707359-1-03.png\" alt=\"\" \/><\/p>\n<h3>Operations of Heap Data Structure:<\/h3>\n<ul>\n<li><strong>Heapify<\/strong>: a process of creating a heap from an array.<\/li>\n<li><strong>Insertion<\/strong>: process to insert an element in existing heap time complexity O(log N).<\/li>\n<li><strong>Deletion<\/strong>: deleting the top element of the heap or the highest priority element, and then organizing the heap and returning the element with time complexity O(log N).<\/li>\n<li><strong>Peek<\/strong>: to check or find the most prior element in the heap, (max or min element for max and min heap).<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663911730005-1-04.png\" alt=\"\" \/><\/p>\n<h3>Types of Heap Data Structure<\/h3>\n<p>Generally, Heaps can be of two types:<\/p>\n<ol>\n<li><strong>Max-Heap<\/strong>: In a Max-Heap the key present at the root node must be greatest among the keys present at all of its children. The same property must be recursively true for all sub-trees in that Binary Tree.<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663911744671-1-05.png\" alt=\"\" \/><\/p>\n<ol start=\"2\">\n<li><strong>Min-Heap<\/strong>: In a Min-Heap the key present at the root node must be minimum among the keys present at all of its children. The same property must be recursively true for all sub-trees in that Binary Tree.<\/li>\n<\/ol>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663930858196-1-06.png\" alt=\"\" \/><\/p>\n<p>Now let&#8217;s see the creation of the heap by using an example.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663932650532-1-11.png\" alt=\"\" \/><\/p>\n<p>The task is to build a max-heap from the above array.<\/p>\n<p>Total nodes = 11<br \/>\nLast non-leaf node index = (11\/2)-1 = 4<br \/>\nTherefore, the last non-leaf node = 6<\/p>\n<p>To build max-heap, heapify only the nodes:<\/p>\n<p>[10,30,50,40,60] in reverse order<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663932716439-1-12.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663931015231-1-07.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663930976482-1-08.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663930950687-1-09.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663930910876-1-10.png\" alt=\"\" \/><\/p>\n<h3>Implementation:<\/h3>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_9897 {\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_9897 .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_9897 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_9897 .wpsm_nav-tabs > li.active > a, #tab_container_9897 .wpsm_nav-tabs > li.active > a:hover, #tab_container_9897 .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_9897 .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_9897 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_9897 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_9897 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_9897 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_9897 .wpsm_nav-tabs > li > a:hover , #tab_container_9897 .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_9897 .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_9897 .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_9897 .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_9897 .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_9897 .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_9897 .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_9897 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9897 .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_9897 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9897 .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_9897 .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_9897\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_9897\">\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_9897_1\" aria-controls=\"tabs_desc_9897_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\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_9897\">\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_9897_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;string.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n#include &lt;stdbool.h&gt;\r\n\r\nint intArray[10];\r\nint size;\r\n\r\nbool isEmpty(){\r\n   return size == 0;\r\n}\r\nint getMinimum(){\r\n   return intArray[0];\r\n}\r\nint getLeftChildIndex(int nodeIndex){\r\n   return 2*nodeIndex +1;\r\n}\r\nint getRightChildIndex(int nodeIndex){\r\n   return 2*nodeIndex +2;\r\n}\r\nint getParentIndex(int nodeIndex){\r\n   return (nodeIndex -1)\/2;\r\n}\r\nbool isFull(){\r\n   return size == 10;\r\n}\r\n\/**\r\n* Heap up the new element,until heap property is broken. \r\n* Steps:\r\n* 1. Compare node's value with parent's value. \r\n* 2. Swap them, If they are in wrong order.\r\n* *\/\r\nvoid heapUp(int nodeIndex){\r\n   int parentIndex, tmp;\r\n   if (nodeIndex != 0) {\r\n      parentIndex = getParentIndex(nodeIndex);\r\n      if (intArray[parentIndex] &gt; intArray[nodeIndex]) {\r\n         tmp = intArray[parentIndex];\r\n         intArray[parentIndex] = intArray[nodeIndex];\r\n         intArray[nodeIndex] = tmp;\r\n         heapUp(parentIndex);\r\n      }\r\n   }\r\n}\r\n\/**\r\n* Heap down the root element being least in value,until heap property is broken. \r\n* Steps:\r\n* 1.If current node has no children, done.  \r\n* 2.If current node has one children and heap property is broken, \r\n* 3.Swap the current node and child node and heap down.\r\n* 4.If current node has one children and heap property is broken, find smaller one\r\n* 5.Swap the current node and child node and heap down.\r\n* *\/\r\nvoid heapDown(int nodeIndex){\r\n   int leftChildIndex, rightChildIndex, minIndex, tmp;\r\n   leftChildIndex = getLeftChildIndex(nodeIndex);\r\n   rightChildIndex = getRightChildIndex(nodeIndex);\r\n   if (rightChildIndex &gt;= size) {\r\n      if (leftChildIndex &gt;= size)\r\n         return;\r\n      else\r\n         minIndex = leftChildIndex;\r\n   } else {\r\n      if (intArray[leftChildIndex] &lt;= intArray[rightChildIndex])\r\n         minIndex = leftChildIndex;\r\n      else\r\n         minIndex = rightChildIndex;\r\n   }\r\n   if (intArray[nodeIndex] &gt; intArray[minIndex]) {\r\n      tmp = intArray[minIndex];\r\n      intArray[minIndex] = intArray[nodeIndex];\r\n      intArray[nodeIndex] = tmp;\r\n      heapDown(minIndex);\r\n   }\r\n}\r\nvoid insert(int value) {            \r\n   size++;\r\n   intArray[size - 1] = value;\r\n   heapUp(size - 1);\r\n}\r\nvoid removeMin() {\r\n   intArray[0] = intArray[size - 1];\r\n   size--;\r\n   if (size &gt; 0)\r\n      heapDown(0);\r\n}\r\nmain() {\r\n   \/*                     5                \/\/Level 0\r\n   * \r\n   *\/\r\n   insert(5);\r\n   \/*                     1                \/\/Level 0\r\n   *                     |\r\n   *                 5---|                 \/\/Level 1\r\n   *\/   \r\n   insert(1);\r\n   \/*                     1                \/\/Level 0\r\n   *                     |\r\n   *                 5---|---3             \/\/Level 1\r\n   *\/\r\n   insert(3);\r\n   \/*                     1                \/\/Level 0\r\n   *                     |\r\n   *                 5---|---3             \/\/Level 1\r\n   *                 |\r\n   *              8--|                     \/\/Level 2\r\n   *\/\r\n   insert(8);\r\n   \/*                     1                \/\/Level 0\r\n   *                     |\r\n   *                 5---|---3             \/\/Level 1\r\n   *                 |\r\n   *              8--|--9                  \/\/Level 2\r\n   *\/\r\n   insert(9);\r\n   \/*                     1                 \/\/Level 0\r\n   *                     |\r\n   *                 5---|---3              \/\/Level 1\r\n   *                 |       |\r\n   *              8--|--9 6--|              \/\/Level 2\r\n   *\/\r\n   insert(6);\r\n   \/*                     1                 \/\/Level 0\r\n   *                     |\r\n   *                 5---|---2              \/\/Level 1\r\n   *                 |       | \r\n   *              8--|--9 6--|--3           \/\/Level 2\r\n   *\/\r\n   insert(2);\r\n\r\n   printf(&quot;%d&quot;, getMinimum());\r\n\r\n   removeMin();\r\n   \/*                     2                 \/\/Level 0\r\n   *                     |\r\n   *                 5---|---3              \/\/Level 1\r\n   *                 |       |\r\n   *              8--|--9 6--|              \/\/Level 2\r\n   *\/\r\n   printf(&quot;&#92;n%d&quot;, getMinimum());   \r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\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_9897 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_9897 a\"),jQuery(\"#tab-content_9897\"));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>Test your data structure skills by taking this <a href=\"https:\/\/www.prepbytes.com\/mock-tests\/ds-algo\/set-1\" title=\"Data Structures using C Mock Test\">Data Structures using C Mock Test<\/a> designed by experienced mentors at <a href=\"https:\/\/www.prepbytes.com\/\" title=\"PrepBytes\">PrepBytes<\/a>.<\/p>\n<p>We tried to discuss Data Structures using C in this article. We hope this article gives you a better understanding of basics in Data Structures using C. <a href=\"https:\/\/www.prepbytes.com\/\" title=\"Prepbytes\">Prepbytes<\/a> also provides a good collection of <a href=\"https:\/\/www.prepbytes.com\/prepbytes-courses\" title=\"Foundation Courses\">Foundation Courses<\/a> that can help you enhance your coding skills. Want to make sure you ace the interview in one go? Join our <a href=\"https:\/\/www.prepbytes.com\/placement-preparation-program\" title=\"Placement Program\">Placement Program<\/a> that will help you get prepared and land your dream job at MNCs. Mentors of Prepbytes are highly experienced and can provide you with basic, in-depth subject knowledge for better understanding.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A data structure is not only used for organizing the data. It is also used for processing, retrieving, and storing data. There are different basic and advanced types of data structures that are used in almost every program or software system that has been developed. So we must have good knowledge about data structures. Data [&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":[191],"tags":[],"class_list":["post-9900","post","type-post","status-publish","format-standard","hentry","category-data-structure"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Data Structures Using C | Data Structure | PrepBytes Blog<\/title>\n<meta name=\"description\" content=\"We tried to discuss Data Structures using C in this article. We hope this article gives you a better understanding of basics in Data Structures using C.\" \/>\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\/data-structures-using-c-queue-heap-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Structures Using C | Data Structure | PrepBytes Blog\" \/>\n<meta property=\"og:description\" content=\"We tried to discuss Data Structures using C in this article. We hope this article gives you a better understanding of basics in Data Structures using C.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/\" \/>\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-09-25T23:26:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-10T08:33:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Data Structures Using C | Queue | Heap\",\"datePublished\":\"2022-09-25T23:26:45+00:00\",\"dateModified\":\"2022-10-10T08:33:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/\"},\"wordCount\":931,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg\",\"articleSection\":[\"Data Structure\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/\",\"name\":\"Data Structures Using C | Data Structure | PrepBytes Blog\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg\",\"datePublished\":\"2022-09-25T23:26:45+00:00\",\"dateModified\":\"2022-10-10T08:33:52+00:00\",\"description\":\"We tried to discuss Data Structures using C in this article. We hope this article gives you a better understanding of basics in Data Structures using C.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Structure\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/data-structure\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Data Structures Using C | Queue | Heap\"}]},{\"@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":"Data Structures Using C | Data Structure | PrepBytes Blog","description":"We tried to discuss Data Structures using C in this article. We hope this article gives you a better understanding of basics in Data Structures using C.","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\/data-structures-using-c-queue-heap-2\/","og_locale":"en_US","og_type":"article","og_title":"Data Structures Using C | Data Structure | PrepBytes Blog","og_description":"We tried to discuss Data Structures using C in this article. We hope this article gives you a better understanding of basics in Data Structures using C.","og_url":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-09-25T23:26:45+00:00","article_modified_time":"2022-10-10T08:33:52+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Data Structures Using C | Queue | Heap","datePublished":"2022-09-25T23:26:45+00:00","dateModified":"2022-10-10T08:33:52+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/"},"wordCount":931,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg","articleSection":["Data Structure"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/","url":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/","name":"Data Structures Using C | Data Structure | PrepBytes Blog","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg","datePublished":"2022-09-25T23:26:45+00:00","dateModified":"2022-10-10T08:33:52+00:00","description":"We tried to discuss Data Structures using C in this article. We hope this article gives you a better understanding of basics in Data Structures using C.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664148351627-Topic%201.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/data-structures-using-c-queue-heap-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Data Structure","item":"https:\/\/prepbytes.com\/blog\/category\/data-structure\/"},{"@type":"ListItem","position":3,"name":"Data Structures Using C | Queue | Heap"}]},{"@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\/9900","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=9900"}],"version-history":[{"count":3,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/9900\/revisions"}],"predecessor-version":[{"id":10173,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/9900\/revisions\/10173"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=9900"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=9900"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=9900"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}