{"id":9218,"date":"2022-08-26T10:39:13","date_gmt":"2022-08-26T10:39:13","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=9218"},"modified":"2022-09-13T13:34:57","modified_gmt":"2022-09-13T13:34:57","slug":"design-a-stack-with-operations-on-middle-element","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/","title":{"rendered":"Design a Stack with operations on Middle element"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg\" alt=\"\" \/><\/p>\n<\/p>\n<h3>Brief about Stack Data structure:<\/h3>\n<p>A stack is a <a href=\"https:\/\/prepbytes.com\/blog\/stacks\/difference-between-stack-and-queue-data-structures\/\">linear data structure<\/a> that follows the principle of Last In First Out (LIFO). This means the last element inserted inside the stack will be on the top of the stack.<\/p>\n<h3>Functions in the stack:-<\/h3>\n<ol>\n<li><strong>push()<\/strong> function that adds an element on the top of the stack.<\/li>\n<li><strong>pop()<\/strong> function that removes an element from the top of the stack.<\/li>\n<\/ol>\n<p><strong>The above two functions are part of the standard stack but we are going to design a new type of stack having these two more functions.<\/strong><\/p>\n<ol start=\"3\">\n<li><strong>findMiddle()<\/strong> function that will return the middle element of the stack.<\/li>\n<li><strong>deleteMiddle()<\/strong> function that will delete the middle element.<\/li>\n<\/ol>\n<h3>Method 1:<\/h3>\n<p>Before starting the implementation of such type of stack we need to think that an array or linked list will be more efficient.<\/p>\n<ol>\n<li>If we choose Array then adding or removing an element from the middle of the array will cost more than O(1).<\/li>\n<li>If we choose a singly linked list then, moving the middle pointer in both directions is not possible.<\/li>\n<li>So, the best idea is to choose a <strong>Doubly Linked List (DLL)<\/strong>. So, We can delete the middle element in O(1) time by maintaining a pointer pointing to the middle of DLL, and here, we can easily move the mid-pointer in both directions using previous and next pointers.<\/li>\n<\/ol>\n<h3>Code 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_9339 {\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_9339 .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_9339 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_9339 .wpsm_nav-tabs > li.active > a, #tab_container_9339 .wpsm_nav-tabs > li.active > a:hover, #tab_container_9339 .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_9339 .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_9339 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_9339 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_9339 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_9339 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_9339 .wpsm_nav-tabs > li > a:hover , #tab_container_9339 .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_9339 .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_9339 .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_9339 .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_9339 .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_9339 .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_9339 .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_9339 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9339 .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_9339 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9339 .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_9339 .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_9339\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_9339\">\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_9339_1\" aria-controls=\"tabs_desc_9339_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_9339\">\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_9339_1\">\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\/* C++ Program to implement a new type of stack\r\nhaving findMiddle() and\r\ndeleteMiddle() functions *\/\r\n \r\n#include &lt;bits\/stdc++.h&gt;\r\nusing namespace std;\r\n \r\nclass myStack {\r\n    struct Node {\r\n        \/\/ members of Node of the LinkedList\r\n        int num;\r\n        Node* next;\r\n        Node* prev;\r\n \r\n        Node(int num) { this-&gt;num = num; }\r\n    };\r\n \r\n    \/\/ members of the stack\r\n    Node* head = NULL;\r\n    Node* mid = NULL;\r\n    int size = 0;\r\n \r\npublic:\r\n  \/\/ push element in the stack\r\n    void push(int data){\r\n        Node* temp = new Node(data);\r\n        if (size == 0) {\r\n            head = temp;\r\n            mid = temp;\r\n            size++;\r\n            return;\r\n        }\r\n \r\n        head-&gt;next = temp;\r\n        temp-&gt;prev = head;\r\n \r\n        \/\/ move head pointer to next of head\r\n        head = head-&gt;next;\r\n        if (size % 2 == 1) {\r\n            mid = mid-&gt;next;\r\n        }\r\n        size++;\r\n    }\r\n \/\/pop element from the stack\r\n    int pop()\r\n    {\r\n      int data=-1;\r\n        if (size != 0) {\r\n          data=head-&gt;num;\r\n            if (size == 1) {\r\n                head = NULL;\r\n                mid = NULL;\r\n            }\r\n            else {\r\n                head = head-&gt;prev;\r\n                head-&gt;next = NULL;\r\n                if (size % 2 == 0) {\r\n                    mid = mid-&gt;prev;\r\n                }\r\n            }\r\n            size--;\r\n        }\r\n      return data;\r\n    }\r\n \/\/ find middle element of the stack\r\n    int findMiddle(){\r\n        if (size == 0) {\r\n            return -1;\r\n        }\r\n        \/\/ mid pointer points to middle of the linked list\r\n        return mid-&gt;num;\r\n    }\r\n \r\n    void deleteMiddle()\r\n    {\r\n        if (size != 0) {\r\n            if (size == 1) {\r\n                head = NULL;\r\n                mid = NULL;\r\n            }\r\n            else if (size == 2) {\r\n                head = head-&gt;prev;\r\n                mid = mid-&gt;prev;\r\n                head-&gt;next = NULL;\r\n            }\r\n            else {\r\n                mid-&gt;next-&gt;prev = mid-&gt;prev;\r\n                mid-&gt;prev-&gt;next = mid-&gt;next;\r\n                if (size % 2 == 0) {\r\n                    mid = mid-&gt;prev;\r\n                }\r\n                else {\r\n                    mid = mid-&gt;next;\r\n                }\r\n            }\r\n            size--;\r\n        }\r\n    }\r\n};\r\n \r\nint main(){  \r\n    myStack s;\r\n    s.push(1);\r\n    s.push(2);\r\n    s.push(3);\r\n    s.push(4);\r\n    s.push(5);\r\n    s.push(6);\r\n    s.push(7);\r\n    cout &lt;&lt;&quot;Top of stack : &quot;&lt;&lt; s.pop() &lt;&lt; endl;\r\n    \/\/one element is popped out of the stack\r\n    cout &lt;&lt;&quot;Top of stack : &quot;&lt;&lt; s.pop() &lt;&lt; endl;\r\n    cout &lt;&lt;&quot;Middle Element of stack: &quot;&lt;&lt; s.findMiddle() &lt;&lt; endl;\r\n    \/\/ middle element of stack deleted\r\n    s.deleteMiddle();\r\n    cout &lt;&lt;&quot;Current Middle Element : &quot;&lt;&lt; s.findMiddle() &lt;&lt; endl;\r\n}\r\n<\/pre>\r\n<!-- \/wp:enlighter\/codeblock -->\r\n\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_9339 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_9339 a\"),jQuery(\"#tab-content_9339\"));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><br \/>\nTop of stack : 7<br \/>\nTop of stack : 6<br \/>\nMiddle Element of stack: 3<br \/>\nCurrent Middle Element : 4<\/p>\n<h3>Method 2:<\/h3>\n<p>Now, we are going to learn a new approach to design a stack with operations on middle element by using a standard stack and a deque.<\/p>\n<p>We will use a standard stack to store half of the elements and the other half of the elements in the deque. By this approach, we will be able to find the middle element very fast<\/p>\n<p>Before every insert operation:-<\/p>\n<ol>\n<li>Before pushing any element we will first check the size of these two containers i.e standard stack and deque. If the size of both containers is the same then just push this element in the deque.<\/li>\n<li>If the size is not equal then pop the front element of the deque and push popped element into the stack and this new element is pushed into the back of the deque.<\/li>\n<\/ol>\n<p>For more clearly see the Dry run below:-<br \/>\n<img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509929325-Design%20a%20Stack%20with%20operations%20on%20middle%20element-1.png\" alt=\"\" \/><\/p>\n<h3>Code 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_9340 {\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_9340 .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_9340 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_9340 .wpsm_nav-tabs > li.active > a, #tab_container_9340 .wpsm_nav-tabs > li.active > a:hover, #tab_container_9340 .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_9340 .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_9340 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_9340 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_9340 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_9340 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_9340 .wpsm_nav-tabs > li > a:hover , #tab_container_9340 .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_9340 .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_9340 .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_9340 .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_9340 .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_9340 .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_9340 .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_9340 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9340 .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_9340 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9340 .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_9340 .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_9340\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_9340\">\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_9340_1\" aria-controls=\"tabs_desc_9340_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_9340\">\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_9340_1\">\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\nclass myStack {\r\n  stack&lt;int&gt; st;\r\n  deque&lt;int&gt; dq;\r\n\r\npublic:\r\n  void add(int element){\r\n    dq.push_back(element);\r\n    if (dq.size() &gt; st.size() + 1) { \/\/ if this condition results true\r\n      \/\/ pop element from dequeue and push into stack\r\n      int temp = dq.front();\r\n      dq.pop_front();\r\n      st.push(temp);\r\n    }\r\n  }\r\n\r\n  void pop(){\r\n    int element = dq.back();\r\n    dq.pop_back();\r\n    if (st.size() &gt; dq.size()) {\r\n      int temp = st.top();\r\n      st.pop();\r\n      dq.push_front(temp);\r\n    }\r\n  }\r\n\r\n  int getMiddleElement() {\r\n    \/\/ front element of the dequeue is the middle element\r\n    return dq.front();\r\n  }\r\n\r\n  void deleteMiddleElement(){\r\n    dq.pop_front();\r\n    if (st.size() &gt; dq.size()) {\r\n     \/\/ new middle element should come at front of deque\r\n      int temp = st.top();    \r\n      st.pop();\r\n      dq.push_front(temp);\r\n    }\r\n  }\r\n};\r\n\r\nint main(){\r\n  myStack s;\r\n  s.add(8);\r\n  s.add(1);\r\n  s.add(5);\r\n  \/\/ printing the middle element\r\n  cout &lt;&lt; &quot;Middle Element: &quot; &lt;&lt; s.getMiddleElement() &lt;&lt; endl;\r\n  s.add(7);\r\n  s.add(2);\r\n  \/\/ printing the middle element\r\n  cout &lt;&lt; &quot;Middle Element: &quot; &lt;&lt; s.getMiddleElement() &lt;&lt; endl;\r\n  \/\/ delete middle element\r\n  s.deleteMiddleElement();\r\n\r\n  cout &lt;&lt; &quot;Middle Element: &quot; &lt;&lt; s.getMiddleElement() &lt;&lt; endl;\r\n  \/\/ delete middle element\r\n  s.deleteMiddleElement();\r\n  cout &lt;&lt; &quot;Middle Element: &quot; &lt;&lt; s.getMiddleElement() &lt;&lt; endl;\r\n  \/\/ pop element on the top of the stack\r\n  s.pop();\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_9340 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_9340 a\"),jQuery(\"#tab-content_9340\"));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><br \/>\nMiddle Element: 1<br \/>\nMiddle Element: 5<br \/>\nMiddle Element: 7<br \/>\nMiddle Element: 1<\/p>\n<p>This article tried to discuss How to Design a Stack with operations on Middle element. Hope this blog helps you understand and solve the problem. To practice more problems you can check out <a href=\"#\"><\/a> at <a href=\"https:\/\/www.prepbytes.com\/\"> PrepBytes<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Brief about Stack Data structure: A stack is a linear data structure that follows the principle of Last In First Out (LIFO). This means the last element inserted inside the stack will be on the top of the stack. Functions in the stack:- push() function that adds an element on the top of the stack. [&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":[127],"tags":[],"class_list":["post-9218","post","type-post","status-publish","format-standard","hentry","category-stacks"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Design a Stack with operations on Middle element | PrepBytes Blog<\/title>\n<meta name=\"description\" content=\"This article tried to discuss How to Design a Stack with operations on Middle element. Hope this blog helps you understand and solve the problem.\" \/>\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\/design-a-stack-with-operations-on-middle-element\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Design a Stack with operations on Middle element | PrepBytes Blog\" \/>\n<meta property=\"og:description\" content=\"This article tried to discuss How to Design a Stack with operations on Middle element. Hope this blog helps you understand and solve the problem.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/\" \/>\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-08-26T10:39:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-13T13:34:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg\" \/>\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\/design-a-stack-with-operations-on-middle-element\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Design a Stack with operations on Middle element\",\"datePublished\":\"2022-08-26T10:39:13+00:00\",\"dateModified\":\"2022-09-13T13:34:57+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/\"},\"wordCount\":447,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg\",\"articleSection\":[\"Stacks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/\",\"name\":\"Design a Stack with operations on Middle element | PrepBytes Blog\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg\",\"datePublished\":\"2022-08-26T10:39:13+00:00\",\"dateModified\":\"2022-09-13T13:34:57+00:00\",\"description\":\"This article tried to discuss How to Design a Stack with operations on Middle element. Hope this blog helps you understand and solve the problem.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Stacks\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/stacks\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Design a Stack with operations on Middle element\"}]},{\"@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":"Design a Stack with operations on Middle element | PrepBytes Blog","description":"This article tried to discuss How to Design a Stack with operations on Middle element. Hope this blog helps you understand and solve the problem.","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\/design-a-stack-with-operations-on-middle-element\/","og_locale":"en_US","og_type":"article","og_title":"Design a Stack with operations on Middle element | PrepBytes Blog","og_description":"This article tried to discuss How to Design a Stack with operations on Middle element. Hope this blog helps you understand and solve the problem.","og_url":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-08-26T10:39:13+00:00","article_modified_time":"2022-09-13T13:34:57+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg","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\/design-a-stack-with-operations-on-middle-element\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Design a Stack with operations on Middle element","datePublished":"2022-08-26T10:39:13+00:00","dateModified":"2022-09-13T13:34:57+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/"},"wordCount":447,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg","articleSection":["Stacks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/","url":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/","name":"Design a Stack with operations on Middle element | PrepBytes Blog","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg","datePublished":"2022-08-26T10:39:13+00:00","dateModified":"2022-09-13T13:34:57+00:00","description":"This article tried to discuss How to Design a Stack with operations on Middle element. Hope this blog helps you understand and solve the problem.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1661509889070-Design%20a%20Stack%20with%20operations%20on%20middle%20element%20Header.jpeg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/design-a-stack-with-operations-on-middle-element\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Stacks","item":"https:\/\/prepbytes.com\/blog\/category\/stacks\/"},{"@type":"ListItem","position":3,"name":"Design a Stack with operations on Middle element"}]},{"@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\/9218","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=9218"}],"version-history":[{"count":5,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/9218\/revisions"}],"predecessor-version":[{"id":9692,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/9218\/revisions\/9692"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=9218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=9218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=9218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}