{"id":11706,"date":"2023-01-17T13:34:03","date_gmt":"2023-01-17T13:34:03","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=11706"},"modified":"2023-06-08T12:47:26","modified_gmt":"2023-06-08T12:47:26","slug":"basic-queue-operations-in-data-structure","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/","title":{"rendered":"Basic Queue Operations in Data Structure"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg\" alt=\"\" \/><\/p>\n<p>In this post, we&#8217;ll talk about what a queue is and how it works. The queue is one of the most used data structures. The most helpful data structure in programming is a queue. The individual who joins the queue first receives the first ticket, similar to the queue for tickets outside a movie theatre. Let&#8217;s go further into queues and fundamental queue operations.<br \/>\n.<\/p>\n<h2>What is Queue?<\/h2>\n<p>The First In First Out (FIFO) rule is used in queues; the first item entered is the first item exited.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177457-Basic%20Queue%20Operations%20In%20Data%20Structure1.png\" alt=\"\" \/><\/p>\n<p>Since 1 was retained in the queue above before 2, it is also the first item to be taken out of the queue. The FIFO principle is followed.<\/p>\n<p>Enqueue and dequeue are programming phrases for adding and deleting items from a queue, respectively.<\/p>\n<p>Any programming language, including C, C++, Java, Python, or C#, can be used to implement the queue because the specification is basically the same.<\/p>\n<h2>Basic Operations of Queue<\/h2>\n<p>The following operations are possible with a queue, which is an object (abstract data structure &#8211; ADT):<\/p>\n<ul>\n<li><strong>Enqueue<\/strong>: Insert an element at the end of the queue.<\/li>\n<li><strong>Dequeue<\/strong>: Simply remove an element from the front of the queue.<\/li>\n<li><strong>IsEmpty<\/strong>: Used to check if the queue is completely empty.<\/li>\n<li><strong>IsFull<\/strong>: Used to check if the queue is completely full.<\/li>\n<li><strong>Peek<\/strong>: Without removing it, obtain the value from the front of the queue.<\/li>\n<\/ul>\n<h3>peek()<\/h3>\n<p>This function is used to see the data at the front of the queue. The peek() function&#8217;s algorithm is as follows \u2212<\/p>\n<p><strong>Algorithm<\/strong><\/p>\n<pre><code>begin procedure peek\n   return queue[front]\nend procedure<\/code><\/pre>\n<p><strong>C programming language implementation of the peek() function \u2212<\/strong><\/p>\n<pre><code>int peek() {\n   return queue[front];\n}<\/code><\/pre>\n<h3>isfull()<\/h3>\n<p>We simply check for the rear pointer to reach at MAXSIZE to check that the queue is full because we are utilizing a single dimension array to create the queue. The algorithm will be different if we retain the queue as a circular linked list. The isfull() function&#8217;s algorithm \u2212<\/p>\n<p><strong>Algorithm<\/strong><\/p>\n<pre><code>begin procedure isfull\n\n   if rear equals to MAXSIZE\n      return true\n   else\n      return false\n   endif\n\nend procedure<\/code><\/pre>\n<p><strong>C programming language implementation of the isfull() function \u2212<\/strong><\/p>\n<pre><code>bool isfull() {\n   if(rear == MAXSIZE - 1)\n      return true;\n   else\n      return false;\n}<\/code><\/pre>\n<h3>isempty()<\/h3>\n<p>This function is used to check if a queue is empty. We can say that a queue is empty if no element is present in it. Also we can find a queue is empty if the front is less than min or front is greater than rear.<\/p>\n<p><strong>Algorithm<\/strong><\/p>\n<pre><code>begin procedure isempty\n\n   if front is less than MIN  OR front is greater than rear\n      return true\n   else\n      return false\n   endif\n\nend procedure<\/code><\/pre>\n<p>If the value of front is less than MIN or 0, it signifies that the queue is not yet initialized, hence empty.<\/p>\n<p><strong>C programming language implementation of the isempty() function \u2212<\/strong><\/p>\n<pre><code>bool isempty() {\n   if(front < 0 || front > rear) \n      return true;\n   else\n      return false;\n}<\/code><\/pre>\n<h3>Enqueue Operation<\/h3>\n<p>Front and rear data pointers are kept in queues. As a result, compared to stack operations, its operations are more complex to implement.<\/p>\n<p>To enqueue (insert) data into a queue, execute these instructions:<\/p>\n<p><strong>Step 1<\/strong>: Determine whether the queue is full.<\/p>\n<p><strong>Step 2<\/strong>: Produce an overflow error and quit if the queue is full.<\/p>\n<p><strong>Step 3<\/strong>: If the queue is not full, move the rear pointer forward to the next empty space.<\/p>\n<p><strong>Step 4<\/strong>: Where the rear is pointing, add the data element to the queue location.<\/p>\n<p><strong>Step 5<\/strong>: Return a success.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177458-Basic%20Queue%20Operations%20In%20Data%20Structure2.png\" alt=\"\" \/><\/p>\n<p>To prepare for any unforeseen circumstances, we may also check to verify if a queue has been initialized or not.<\/p>\n<p><strong>Algorithm for enqueue operation<\/strong><\/p>\n<pre><code>procedure enqueue(data)      \n\n   if queue is full\n      return overflow\n   endif\n\n   rear \u2190 rear + 1\n   queue[rear] \u2190 data\n   return true\n\nend procedure<\/code><\/pre>\n<p><strong>C programming language implementation of the enqueue() function \u2212<\/strong><\/p>\n<pre><code>int enqueue(int data)      \n   if(isfull())\n      return 0;\n\n   rear = rear + 1;\n   queue[rear] = data;\n\n   return 1;<\/code><\/pre>\n<h3>Dequeue Operation<\/h3>\n<p>It takes two steps to access data from a queue: first, access the data where the front is pointing, and second, remove the data after access. The dequeue operation is carried out in the manner described below:<\/p>\n<p><strong>Step1<\/strong>: Check whether the queue is empty.<\/p>\n<p><strong>Step 2<\/strong>: If there is no one in the queue, generate an underflow error and exit.<\/p>\n<p><strong>Step 3<\/strong>: Access the information at the front of the queue if it is not empty.<\/p>\n<p><strong>Step 4<\/strong>: Increment the front pointer to the next element.<\/p>\n<p><strong>Step 5<\/strong>: Successful return.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177471-Basic%20Queue%20Operations%20In%20Data%20Structure3.png\" alt=\"\" \/><\/p>\n<p><strong>Algorithm for dequeue operation<\/strong><\/p>\n<pre><code>procedure dequeue\n\n   if queue is empty\n      return underflow\n   end if\n\n   data = queue[front]\n   front \u2190 front + 1\n   return true\n\nend procedure<\/code><\/pre>\n<p><strong>C programming language implementation of the dequeue() function \u2212<\/strong><\/p>\n<pre><code>int dequeue() {\n   if(isempty())\n      return 0;\n\n   int data = queue[front];\n   front = front + 1;\n\n   return data;\n}<\/code><\/pre>\n<p>Let&#8217;s combine and see the program having all the basic queue operations.<\/p>\n<h2>Queue Implementation in Python, Java, C, and C++<\/h2>\n<p>In Java and C++, queues are typically implemented using arrays. For Python, we make use of lists.<\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_11707 {\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_11707 .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_11707 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_11707 .wpsm_nav-tabs > li.active > a, #tab_container_11707 .wpsm_nav-tabs > li.active > a:hover, #tab_container_11707 .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_11707 .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_11707 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_11707 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_11707 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_11707 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_11707 .wpsm_nav-tabs > li > a:hover , #tab_container_11707 .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_11707 .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_11707 .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_11707 .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_11707 .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_11707 .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_11707 .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_11707 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11707 .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_11707 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_11707 .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_11707 .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_11707\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_11707\">\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_11707_1\" aria-controls=\"tabs_desc_11707_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_11707_2\" aria-controls=\"tabs_desc_11707_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_11707_3\" aria-controls=\"tabs_desc_11707_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_11707_4\" aria-controls=\"tabs_desc_11707_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_11707\">\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_11707_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"c\">#include &lt;stdio.h&gt;\r\n#define SIZE 5\r\n\r\nvoid enQueue(int);\r\nvoid deQueue();\r\nvoid display();\r\n\r\nint items[SIZE], front = -1, rear = -1;\r\n\r\nint main() {\r\n  \/\/deQueue is not possible on empty queue\r\n  deQueue();\r\n\r\n  \/\/enQueue 5 elements\r\n  enQueue(1);\r\n  enQueue(2);\r\n  enQueue(3);\r\n  enQueue(4);\r\n  enQueue(5);\r\n\r\n  \/\/ 6th element can't be added to because the queue is full\r\n  enQueue(6);\r\n\r\n  display();\r\n\r\n  \/\/deQueue removes element entered first i.e. 1\r\n  deQueue();\r\n\r\n  \/\/Now we have just 4 elements\r\n  display();\r\n\r\n  return 0;\r\n}\r\n\r\nvoid enQueue(int value) {\r\n  if (rear == SIZE - 1)\r\n    printf(\"&#92;nQueue is Full!!\");\r\n  else {\r\n    if (front == -1)\r\n      front = 0;\r\n    rear++;\r\n    items[rear] = value;\r\n    printf(\"&#92;nInserted -&gt; %d\", value);\r\n  }\r\n}\r\n\r\nvoid deQueue() {\r\n  if (front == -1)\r\n    printf(\"&#92;nQueue is Empty!!\");\r\n  else {\r\n    printf(\"&#92;nDeleted : %d\", items[front]);\r\n    front++;\r\n    if (front &gt; rear)\r\n      front = rear = -1;\r\n  }\r\n}\r\n\r\n\/\/ Function to print the queue\r\nvoid display() {\r\n  if (rear == -1)\r\n    printf(\"&#92;nQueue is Empty!!!\");\r\n  else {\r\n    int i;\r\n    printf(\"&#92;nQueue elements are:&#92;n\");\r\n    for (i = front; i &lt;= rear; i++)\r\n      printf(\"%d  \", items[i]);\r\n  }\r\n  printf(\"&#92;n\");\r\n}<\/pre>\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_11707_2\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"cpp\">#include &lt;iostream&gt;\r\n#define SIZE 5\r\n\r\nusing namespace std;\r\n\r\nclass Queue {\r\n   private:\r\n  int items[SIZE], front, rear;\r\n\r\n   public:\r\n  Queue() {\r\n    front = -1;\r\n    rear = -1;\r\n  }\r\n\r\n  bool isFull() {\r\n    if (front == 0 &amp;&amp; rear == SIZE - 1) {\r\n      return true;\r\n    }\r\n    return false;\r\n  }\r\n\r\n  bool isEmpty() {\r\n    if (front == -1)\r\n      return true;\r\n    else\r\n      return false;\r\n  }\r\n\r\n  void enQueue(int element) {\r\n    if (isFull()) {\r\n      cout &lt;&lt; \"Queue is full\";\r\n    } else {\r\n      if (front == -1) front = 0;\r\n      rear++;\r\n      items[rear] = element;\r\n      cout &lt;&lt; endl\r\n         &lt;&lt; \"Inserted \" &lt;&lt; element &lt;&lt; endl;\r\n    }\r\n  }\r\n\r\n  int deQueue() {\r\n    int element;\r\n    if (isEmpty()) {\r\n      cout &lt;&lt; \"Queue is empty\" &lt;&lt; endl;\r\n      return (-1);\r\n    } else {\r\n      element = items[front];\r\n      if (front &gt;= rear) {\r\n        front = -1;\r\n        rear = -1;\r\n      } \/* Q has only one element, so we reset the queue after deleting it. *\/\r\n      else {\r\n        front++;\r\n      }\r\n      cout &lt;&lt; endl\r\n         &lt;&lt; \"Deleted -&gt; \" &lt;&lt; element &lt;&lt; endl;\r\n      return (element);\r\n    }\r\n  }\r\n\r\n  void display() {\r\n    \/* Function to display elements of Queue *\/\r\n    int i;\r\n    if (isEmpty()) {\r\n      cout &lt;&lt; endl\r\n         &lt;&lt; \"Empty Queue\" &lt;&lt; endl;\r\n    } else {\r\n      cout &lt;&lt; endl\r\n         &lt;&lt; \"Front index-&gt; \" &lt;&lt; front;\r\n      cout &lt;&lt; endl\r\n         &lt;&lt; \"Items -&gt; \";\r\n      for (i = front; i &lt;= rear; i++)\r\n        cout &lt;&lt; items[i] &lt;&lt; \"  \";\r\n      cout &lt;&lt; endl\r\n         &lt;&lt; \"Rear index-&gt; \" &lt;&lt; rear &lt;&lt; endl;\r\n    }\r\n  }\r\n};\r\n\r\nint main() {\r\n  Queue q;\r\n\r\n  \/\/deQueue is not possible on empty queue\r\n  q.deQueue();\r\n\r\n  \/\/enQueue 5 elements\r\n  q.enQueue(1);\r\n  q.enQueue(2);\r\n  q.enQueue(3);\r\n  q.enQueue(4);\r\n  q.enQueue(5);\r\n\r\n  \/\/ 6th element can't be added to because the queue is full\r\n  q.enQueue(6);\r\n\r\n  q.display();\r\n\r\n  \/\/deQueue removes element entered first i.e. 1\r\n  q.deQueue();\r\n\r\n  \/\/Now we have just 4 elements\r\n  q.display();\r\n\r\n  return 0;\r\n}<\/pre>\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_11707_3\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"java\">class Queue {\r\n  int SIZE = 5;\r\n  int items[] = new int[SIZE];\r\n  int front, rear;\r\n\r\n  Queue() {\r\n    front = -1;\r\n    rear = -1;\r\n  }\r\n\r\n  boolean isFull() {\r\n    if (front == 0 &amp;&amp; rear == SIZE - 1) {\r\n      return true;\r\n    }\r\n    return false;\r\n  }\r\n\r\n  boolean isEmpty() {\r\n    if (front == -1)\r\n      return true;\r\n    else\r\n      return false;\r\n  }\r\n\r\n  void enQueue(int element) {\r\n    if (isFull()) {\r\n      System.out.println(\"Queue is full\");\r\n    } else {\r\n      if (front == -1)\r\n        front = 0;\r\n      rear++;\r\n      items[rear] = element;\r\n      System.out.println(\"Inserted \" + element);\r\n    }\r\n  }\r\n\r\n  int deQueue() {\r\n    int element;\r\n    if (isEmpty()) {\r\n      System.out.println(\"Queue is empty\");\r\n      return (-1);\r\n    } else {\r\n      element = items[front];\r\n      if (front &gt;= rear) {\r\n        front = -1;\r\n        rear = -1;\r\n      } \/* Q has only one element, so we reset the queue after deleting it. *\/\r\n      else {\r\n        front++;\r\n      }\r\n      System.out.println(\"Deleted -&gt; \" + element);\r\n      return (element);\r\n    }\r\n  }\r\n\r\n  void display() {\r\n    \/* Function to display elements of Queue *\/\r\n    int i;\r\n    if (isEmpty()) {\r\n      System.out.println(\"Empty Queue\");\r\n    } else {\r\n      System.out.println(\"&#92;nFront index-&gt; \" + front);\r\n      System.out.println(\"Items -&gt; \");\r\n      for (i = front; i &lt;= rear; i++)\r\n        System.out.print(items[i] + \"  \");\r\n\r\n      System.out.println(\"&#92;nRear index-&gt; \" + rear);\r\n    }\r\n  }\r\n\r\n  public static void main(String[] args) {\r\n    Queue q = new Queue();\r\n\r\n    \/\/ deQueue is not possible on empty queue\r\n    q.deQueue();\r\n\r\n    \/\/ enQueue 5 elements\r\n    q.enQueue(1);\r\n    q.enQueue(2);\r\n    q.enQueue(3);\r\n    q.enQueue(4);\r\n    q.enQueue(5);\r\n\r\n    \/\/ 6th element can't be added to because the queue is full\r\n    q.enQueue(6);\r\n\r\n    q.display();\r\n\r\n    \/\/ deQueue removes element entered first i.e. 1\r\n    q.deQueue();\r\n\r\n    \/\/ Now we have just 4 elements\r\n    q.display();\r\n\r\n  }\r\n}<\/pre>\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_11707_4\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">class Queue:\r\n\r\n    def __init__(self):\r\n        self.queue = []\r\n\r\n    # Add an element\r\n    def enqueue(self, item):\r\n        self.queue.append(item)\r\n\r\n    # Remove an element\r\n    def dequeue(self):\r\n        if len(self.queue) &lt; 1:\r\n            return None\r\n        return self.queue.pop(0)\r\n\r\n    # Display  the queue\r\n    def display(self):\r\n        print(self.queue)\r\n\r\n    def size(self):\r\n        return len(self.queue)\r\n\r\n\r\nq = Queue()\r\nq.enqueue(1)\r\nq.enqueue(2)\r\nq.enqueue(3)\r\nq.enqueue(4)\r\nq.enqueue(5)\r\n\r\nq.display()\r\n\r\nq.dequeue()\r\n\r\nprint(\"After removing an element\")\r\nq.display()\r\n<\/pre>\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_11707 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_11707 a\"),jQuery(\"#tab-content_11707\"));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>Output<\/strong><\/p>\n<pre><code>Queue is Empty!!\nInserted -> 1\nInserted -> 2\nInserted -> 3\nInserted -> 4\nInserted -> 5\nQueue is Full!!\nQueue elements are:\n1  2  3  4  5  \n\nDeleted : 1\nQueue elements are:\n2  3  4  5  <\/code><\/pre>\n<p><strong>Conclusion<\/strong><br \/>\nHoping this article has explained what is queue and what are the basic queue operations. Queues are a very important topic in terms of data structures. Practice more and more to become an expert in data structures.In conclusion, understanding basic queue operations is essential for effectively implementing and utilizing queues in data structures. Queues provide a straightforward approach to managing elements in a First-In-First-Out (FIFO) manner. The main operations associated with queues are enqueue (adding elements to the rear of the queue) and dequeue (removing elements from the front of the queue). Additionally, we have explored other frequently asked questions (FAQs) related to basic queue operations to provide further clarity on the topic.<\/p>\n<h2>Frequently Asked Questions (FAQs) related to Basic Queue Operations:<\/h2>\n<p><strong>Q1. What is a queue in data structure?<\/strong><br \/>\nA queue is an abstract data type that follows the First-In-First-Out (FIFO) principle. It represents a collection of elements where new elements are added to the rear and existing elements are removed from the front.<\/p>\n<p><strong>Q2. What are the basic operations performed on a queue?<\/strong><br \/>\nThe basic operations performed on a queue are:<br \/>\nEnqueue: Adds an element to the rear of the queue.<br \/>\nDequeue: Removes an element from the front of the queue.<br \/>\nIsEmpty: Checks if the queue is empty.<br \/>\nIsFull: Checks if the queue is full (applies to fixed-size queues).<br \/>\nFront: Retrieves the element at the front of the queue without removing it.<\/p>\n<p><strong>Q3. How is a queue different from a stack?<\/strong><br \/>\nQueues and stacks are both linear data structures, but they differ in their principle of access. A queue follows the FIFO principle, while a stack follows the LIFO (Last-In-First-Out) principle. In a stack, the last element added is the first one to be removed, whereas in a queue, the first element added is the first one to be removed.<\/p>\n<p><strong>Q4. What is the time complexity of enqueue and dequeue operations in a queue?<\/strong><br \/>\nThe time complexity of enqueue and dequeue operations in a standard queue implementation is O(1) (constant time). It means that the time taken to perform these operations does not depend on the number of elements present in the queue.<\/p>\n<p><strong>Q5. Can a queue be implemented using an array?<\/strong><br \/>\nYes, a queue can be implemented using an array. In such an implementation, the rear of the queue is associated with the end of the array, and the front is associated with the beginning. However, it is important to handle cases of overflow (when the queue is full) and underflow (when the queue is empty) properly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we&#8217;ll talk about what a queue is and how it works. The queue is one of the most used data structures. The most helpful data structure in programming is a queue. The individual who joins the queue first receives the first ticket, similar to the queue for tickets outside a movie theatre. [&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":[128],"tags":[],"class_list":["post-11706","post","type-post","status-publish","format-standard","hentry","category-queues"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Basic Queue Operations in Data Structure | Queues | PrepBytes Blog<\/title>\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\/basic-queue-operations-in-data-structure\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basic Queue Operations in Data Structure | Queues | PrepBytes Blog\" \/>\n<meta property=\"og:description\" content=\"In this post, we&#8217;ll talk about what a queue is and how it works. The queue is one of the most used data structures. The most helpful data structure in programming is a queue. The individual who joins the queue first receives the first ticket, similar to the queue for tickets outside a movie theatre. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/\" \/>\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=\"2023-01-17T13:34:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-08T12:47:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Basic Queue Operations in Data Structure\",\"datePublished\":\"2023-01-17T13:34:03+00:00\",\"dateModified\":\"2023-06-08T12:47:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/\"},\"wordCount\":1090,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg\",\"articleSection\":[\"Queues\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/\",\"name\":\"Basic Queue Operations in Data Structure | Queues | PrepBytes Blog\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg\",\"datePublished\":\"2023-01-17T13:34:03+00:00\",\"dateModified\":\"2023-06-08T12:47:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Queues\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/queues\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Basic Queue Operations in Data Structure\"}]},{\"@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":"Basic Queue Operations in Data Structure | Queues | PrepBytes Blog","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\/basic-queue-operations-in-data-structure\/","og_locale":"en_US","og_type":"article","og_title":"Basic Queue Operations in Data Structure | Queues | PrepBytes Blog","og_description":"In this post, we&#8217;ll talk about what a queue is and how it works. The queue is one of the most used data structures. The most helpful data structure in programming is a queue. The individual who joins the queue first receives the first ticket, similar to the queue for tickets outside a movie theatre. [&hellip;]","og_url":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2023-01-17T13:34:03+00:00","article_modified_time":"2023-06-08T12:47:26+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Basic Queue Operations in Data Structure","datePublished":"2023-01-17T13:34:03+00:00","dateModified":"2023-06-08T12:47:26+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/"},"wordCount":1090,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg","articleSection":["Queues"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/","url":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/","name":"Basic Queue Operations in Data Structure | Queues | PrepBytes Blog","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg","datePublished":"2023-01-17T13:34:03+00:00","dateModified":"2023-06-08T12:47:26+00:00","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1673962177351-Basic%20Queue%20Operations%20In%20Data%20Structure.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/basic-queue-operations-in-data-structure\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Queues","item":"https:\/\/prepbytes.com\/blog\/category\/queues\/"},{"@type":"ListItem","position":3,"name":"Basic Queue Operations in Data Structure"}]},{"@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\/11706","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=11706"}],"version-history":[{"count":4,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11706\/revisions"}],"predecessor-version":[{"id":16731,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/11706\/revisions\/16731"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=11706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=11706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=11706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}