{"id":9618,"date":"2022-09-13T12:11:04","date_gmt":"2022-09-13T12:11:04","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=9618"},"modified":"2022-10-03T03:58:45","modified_gmt":"2022-10-03T03:58:45","slug":"iterative-postorder-traversal-set-1-using-two-stacks","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/","title":{"rendered":"Iterative Postorder Traversal | Set 1 (Using Two Stacks)"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg\" alt=\"\" \/><\/p>\n<h3>Problem Statement<\/h3>\n<p>You are given a <a href=\"https:\/\/prepbytes.com\/blog\/trees\/\" title=\"binary tree\">binary tree<\/a>. Your task is to print the postorder traversal of the tree iteratively, using 2 stacks.<\/p>\n<p><strong>Example<\/strong><\/p>\n<p>Consider the tree given below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662980603847-8-01.png\" alt=\"\" \/><\/p>\n<p>The postorder traversal means that we have to travel the children of every node before visiting the node in the order \u201cleft right node\u201d. Hence, the postorder traversal of the given tree is shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662980678171-8-02.png\" alt=\"\" \/><\/p>\n<p>So, let us now discuss the approach.<\/p>\n<h3>What is Postorder Traversal?<\/h3>\n<p>Before we directly jump into the solution, let us first discuss in detail, what postorder traversal is. Consider the tree given below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662980736255-8-03.png\" alt=\"\" \/><\/p>\n<p>We are currently at the root node of the tree. There are three different types of traversals. The <strong>preorder<\/strong> traversal says that we have to follow the order \u201c<strong>root left right<\/strong>\u201d. This means that as soon as we are at a node, we have to mark it visited. <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662980865951-8-04.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662980929525-8-05.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662980966893-8-06.png\" alt=\"\" \/><\/p>\n<p>The images above show that as soon as we reach a node in our traversal, consider it visited. So, the complete preorder traversal is shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981035557-8-07.png\" alt=\"\" \/><\/p>\n<p>The <strong>inorder<\/strong> traversal has the order of \u201c<strong>left root right<\/strong>\u201d. This means that first we explore the left subtree, then mark the current node as visited, and then visit the right subtree. This is shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981291788-8-08.png\" alt=\"\" \/><\/p>\n<p>Traversing till here, we have not marked any node visited as we kept on visiting the left node. Now, node 4 does not have any left node. So, we can say that we have traversed its left node. Now, the order is \u201cleft node right\u201d, so after visiting the left node, we have to mark the node visited. Hence, we mark node 4 as visited.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981255172-8-09.png\" alt=\"\" \/><\/p>\n<p>Similarly, the entire tree is traversed.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981403723-8-10.png\" alt=\"\" \/><\/p>\n<p>Now, the <strong>postorder<\/strong> traversal has the order \u201c<strong>left right root<\/strong>\u201d. This means that we have to first traverse the left subtree completely, then traverse the right subtree completely, and at the last, we have to mark the current node visited.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981856611-8-11.png\" alt=\"\" \/><\/p>\n<p>Till here, we have not visited any node because we kept on moving to the left node of every node. Now, at Node 4, we see that there is no left node. So, we can say that we have visited the left node. Also, there is no right node. Hence, we can say that we have visited the right node also. So, now we can mark the current node visited. So, Node 4 is the first node in the postorder traversal.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981891144-8-12.png\" alt=\"\" \/><\/p>\n<p>We keep on moving further as shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981924763-8-12.png\" alt=\"\" \/><\/p>\n<p>At Node 8, we don\u2019t have any left or right nodes. Hence, we can say that we have visited the left and right nodes of Node 8. So, mark it visited as well.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662981980662-8-13.png\" alt=\"\" \/><\/p>\n<p>Now, we reach node 5 again. Here, we can see that we have visited the left subtree of 5. There is no right child for Node 5. Hence, we can say that we have visited both the children. So, let us include 5 in the postorder traversal too.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662982009434-8-14.png\" alt=\"\" \/><\/p>\n<p>When we are at Node 2, we have already visited the left subtree (Node 4) and the right subtree (starting from Node 5) as well. So, we can now mark Node 2 as visited.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662982045311-8-15.png\" alt=\"\" \/><\/p>\n<p>Similarly, you can complete the rest of the traversal as well. The complete postorder traversal of the tree is shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662982152670-8-16.png\" alt=\"\" \/><\/p>\n<p>So, for better understanding, have a look at the image shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662982453176-8-17.png\" alt=\"\" \/><\/p>\n<p>Whenever we are on the <strong>left of any node<\/strong> i.e. no child has been traversed yet, we say that we are in a <strong>pre-node<\/strong> region. Whenever we are in the <strong>middle of the left and right child of a node<\/strong> i.e. the left subtree has been traversed but the right subtree has not been traversed, we are in the <strong>in-node<\/strong> region. Similarly, whenever we are in the <strong>right of a node<\/strong> i.e. both its children have been traversed, we are in the <strong>post-node<\/strong> region.<\/p>\n<p>Now that we have a complete understanding of different tree traversals, let us approach our problem i.e. postorder traversal using 2 stacks.<\/p>\n<h3>Approach (Using 2 Stacks)<\/h3>\n<p>We know that the postorder traversal is \u201cleft right root\u201d. Using 2 stacks, the basic idea is to get the reverse of the postorder into one stack so that when we pop all the elements from that stack, we get the postorder traversal due to the FILO (or LIFO) principle of the stack.<\/p>\n<p>So, what is the reverse of postorder? It is \u201croot right left\u201d. This is very similar to the preorder traversal. Only we have to visit the right child first, before visiting the left child.<\/p>\n<p>So, let us consider two stacks and the tree as shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662982475752-8-18.png\" alt=\"\" \/><\/p>\n<p>The initial step is to push the root of the tree into Stack 1. Now, we will follow the following algorithm.<\/p>\n<pre><code>while(!stack1.empty())\n    curr=top of stack1\n    pop from stack1\n    push curr on stack2\n    if(curr -&gt; left != NULL)\n        push curr -&gt; left on stack1\n    if(curr -&gt; right !=NULL)\n        push curr -&gt; right on stack1<\/code><\/pre>\n<p>So, according to the above algorithm, since Stack 1 is not empty, we pop it and push the element into Stack 2.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662982517182-8-19.png\" alt=\"\" \/><\/p>\n<p>Now, the current node i.e. Node 1 has both left and right children. So, push the left child into Stack 1 first and then push the right child too.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662982959847-8-20.png\" alt=\"\" \/><\/p>\n<p>Now, we pop Node 3 from Stack 1 and push it into Stack 2. We also add the left and right children of Node 3 to Stack 1.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983099128-8-21.png\" alt=\"\" \/><\/p>\n<p>Since Node 7 does not have any children, it just gets popped from Stack 1 and gets added to Stack 2.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983157504-8-22.png\" alt=\"\" \/><\/p>\n<p>Now, we pop Node 6 from Stack 1, push it into Stack 2, and push its right child Node 9 into Stack 1.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983200976-8-23.png\" alt=\"\" \/><\/p>\n<p>Now, Node 9 gets popped from Stack 1 and gets pushed into Stack 2.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983244290-8-24.png\" alt=\"\" \/><\/p>\n<p>Now we pop Node 2 from Stack 1 and push it into Stack 2. Also, the children of Node 2 i.e Node 4 and Node 5 get pushed into Stack 1.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983303149-8-25.png\" alt=\"\" \/><\/p>\n<p>Now, Node 5 will pop out from Stack 1 and push to Stack 2. Also, its child i.e. Node 8 will be pushed into Stack 1.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983383227-8-26.png\" alt=\"\" \/><\/p>\n<p>Now, Node 8 and Node 4 will be popped one by one from Stack 1 and pushed into Stack 2. Since they don\u2019t have any children, Stack 1 will become empty.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983421877-8-27.png\" alt=\"\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1663070992958-8-29.png\" alt=\"\" \/><\/p>\n<p>So, now that Stack 1 is empty, we just have to pop all the elements from Stack 2 and as soon as an element is popped from Stack 2, we print it. Thus, we will get the postorder traversal.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662983470829-8-28.png\" alt=\"\" \/><\/p>\n<p>Hence, we have completed the procedure.<\/p>\n<p><strong>Why did this work?<\/strong><\/p>\n<p>We wanted the order \u201c<strong>left right root<\/strong>\u201d. So, we pushed the order \u201c<strong>root left right<\/strong>\u201d into <strong>Stack 1<\/strong>. We popped the elements from Stack 1 and pushed them to Stack 2. Now, if we look carefully, on popping the elements from Stack 1, the order will be reversed of the order in which they were pushed i.e. the order will be \u201c<strong>root right left<\/strong>\u201d and this will be pushed into <strong>Stack 2<\/strong> . This is because of the LIFO property of the stack. <\/p>\n<p>Now, when we pop the elements from Stack 2, the order will reverse the order in which they were pushed. Since the elements were pushed in the order \u201croot right left\u201d, the order that we get on popping the elements from Stack 2 is \u201cleft right root\u201d.<\/p>\n<p>This is nothing but the postorder traversal.<\/p>\n<p>So, this was the complete procedure of the iterative postorder traversal using 2 Stacks. Now that we have understood the complete procedure, let us write the code for the same.<\/p>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_9641 {\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_9641 .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_9641 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_9641 .wpsm_nav-tabs > li.active > a, #tab_container_9641 .wpsm_nav-tabs > li.active > a:hover, #tab_container_9641 .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_9641 .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_9641 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_9641 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_9641 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_9641 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_9641 .wpsm_nav-tabs > li > a:hover , #tab_container_9641 .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_9641 .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_9641 .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_9641 .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_9641 .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_9641 .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_9641 .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_9641 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9641 .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_9641 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_9641 .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_9641 .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_9641\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_9641\">\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_9641_1\" aria-controls=\"tabs_desc_9641_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_9641_2\" aria-controls=\"tabs_desc_9641_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>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\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_9641\">\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_9641_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\n\/\/tree node \r\nstruct Node {\r\n\r\n\tint data;\r\n\tNode *left, *right;\r\n};\r\n\r\n\r\nNode* newNode(int data)\r\n{\r\n\tNode* node = new Node;\r\n\tnode-&gt;data = data;\r\n\tnode-&gt;left = node-&gt;right = NULL;\r\n\treturn node;\r\n}\r\n\r\nvoid post_order_iterative(Node* root)\r\n{\r\n\tif (root == NULL)\r\n\t\treturn;\r\n\t\t\r\n\tstack&lt;Node *&gt; s1, s2;\r\n\r\n\t\r\n\ts1.push(root);\r\n\tNode* node;\r\n\r\n\t\r\n\twhile (!s1.empty()) {\r\n\t\t\r\n\t\t\/\/pop from stack 1 and add the elemnt to stack 2\r\n\t\tnode = s1.top();\r\n\t\ts1.pop();\r\n\t\ts2.push(node);\r\n\r\n\t\t\/\/add children to stack 1\r\n\t\tif (node-&gt;left)\r\n\t\t\ts1.push(node-&gt;left);\r\n\t\tif (node-&gt;right)\r\n\t\t\ts1.push(node-&gt;right);\r\n\t}\r\n\r\n\t\/\/ Print all elements of second stack -&gt; this is postorder traversal\r\n\twhile (!s2.empty()) {\r\n\t\tnode = s2.top();\r\n\t\ts2.pop();\r\n\t\tcout &lt;&lt; node-&gt;data &lt;&lt; &quot; &quot;;\r\n\t}\r\n}\r\n\r\nint main()\r\n{\r\n\t\/\/The tree that we have been discussing so far\r\n\tNode* root = NULL;\r\n\troot = newNode(1);\r\n\troot-&gt;left = newNode(2);\r\n\troot-&gt;right = newNode(3);\r\n\troot-&gt;left-&gt;left = newNode(4);\r\n\troot-&gt;left-&gt;right = newNode(5);\r\n\troot-&gt;right-&gt;left = newNode(6);\r\n\troot-&gt;right-&gt;right = newNode(7);\r\n    root-&gt;left-&gt;right-&gt;left = newNode(8);\r\n    root-&gt;right-&gt;left-&gt;right = newNode(9);\r\n\r\n\tpost_order_iterative(root);\r\n\r\n\treturn 0;\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\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane \" id=\"tabs_desc_9641_2\">\r\n\t\t\t\t\t\t\t\t<!-- wp:enlighter\/codeblock {\"language\":\"Java\"} -->\r\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"Java\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\r\nimport java.util.*;\r\npublic class Main {\r\n\r\n\tstatic class node {\r\n\t\tint data;\r\n\t\tnode left, right;\r\n\r\n\t\tpublic node(int data)\r\n\t\t{\r\n\t\t\tthis.data = data;\r\n\t\t}\r\n\t}\r\n\r\n\tstatic Stack&lt;node&gt; s1, s2;\r\n\r\n\tstatic void postOrderIterative(node root)\r\n\t{\r\n\t\ts1 = new Stack&lt;&gt;();\r\n\t\ts2 = new Stack&lt;&gt;();\r\n\r\n\t\tif (root == null)\r\n\t\t\treturn;\r\n\r\n\t\t\/\/ push root to first stack\r\n\t\ts1.push(root);\r\n\r\n\t\twhile (!s1.isEmpty()) {\r\n\t\t\t\/\/ Pop an item from stack 1 and push it to stack 2\r\n\t\t\tnode temp = s1.pop();\r\n\t\t\ts2.push(temp);\r\n\r\n            \/\/add children of current node to stack 1\r\n\t\t\tif (temp.left != null)\r\n\t\t\t\ts1.push(temp.left);\r\n\t\t\tif (temp.right != null)\r\n\t\t\t\ts1.push(temp.right);\r\n\t\t}\r\n\r\n\t\t\/\/ Print all elements of second stack -&gt; this is the postorder traversal\r\n\t\twhile (!s2.isEmpty()) {\r\n\t\t\tnode temp = s2.pop();\r\n\t\t\tSystem.out.print(temp.data + &quot; &quot;);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static void main(String[] args)\r\n\t{   \r\n\t    \/\/tree that we have been discussing so far\r\n\t\tnode root = null;\r\n\t\troot = new node(1);\r\n\t\troot.left = new node(2);\r\n\t\troot.right = new node(3);\r\n\t\troot.left.left = new node(4);\r\n\t\troot.left.right = new node(5);\r\n\t\troot.right.left = new node(6);\r\n\t\troot.right.right = new node(7);\r\n\t\troot.left.right.left = new node(8);\r\n        root.right.left.right = new node(9);\r\n\t\t\r\n\r\n\t\tpostOrderIterative(root);\r\n\t}\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_9641 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_9641 a\"),jQuery(\"#tab-content_9641\"));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>Time Complexity<\/strong><\/p>\n<p>The time complexity of this procedure is O(N) where N is the number of nodes in the tree. This is because we have to traverse all the nodes of the tree once in order to print them.<\/p>\n<p><strong>Space Complexity<\/strong><\/p>\n<p>The space complexity of this approach is O(N). This is because we are using 2 stacks and Stack 2 at the end contains all the N nodes of the tree.<\/p>\n<p>This article tried to discuss Iterative Postorder Traversal. Hope this blog helps you understand and solve the problem. To practice more problems you can check out <a href=\"#\" title=\"\"><\/a> at <a href=\"https:\/\/www.prepbytes.com\/\" title=\"Prepbytes\">Prepbytes<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Statement You are given a binary tree. Your task is to print the postorder traversal of the tree iteratively, using 2 stacks. Example Consider the tree given below. The postorder traversal means that we have to travel the children of every node before visiting the node in the order \u201cleft right node\u201d. Hence, the [&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-9618","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>Iterative Postorder Traversal | Set 1 (Using Two Stacks)<\/title>\n<meta name=\"description\" content=\"This article tried to discuss Iterative Postorder Traversal. Hope this blog helps you understand and solve the problems in the interviews.\" \/>\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\/iterative-postorder-traversal-set-1-using-two-stacks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Iterative Postorder Traversal | Set 1 (Using Two Stacks)\" \/>\n<meta property=\"og:description\" content=\"This article tried to discuss Iterative Postorder Traversal. Hope this blog helps you understand and solve the problems in the interviews.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/\" \/>\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-13T12:11:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-03T03:58:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Iterative Postorder Traversal | Set 1 (Using Two Stacks)\",\"datePublished\":\"2022-09-13T12:11:04+00:00\",\"dateModified\":\"2022-10-03T03:58:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/\"},\"wordCount\":1277,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg\",\"articleSection\":[\"Stacks\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/\",\"name\":\"Iterative Postorder Traversal | Set 1 (Using Two Stacks)\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg\",\"datePublished\":\"2022-09-13T12:11:04+00:00\",\"dateModified\":\"2022-10-03T03:58:45+00:00\",\"description\":\"This article tried to discuss Iterative Postorder Traversal. Hope this blog helps you understand and solve the problems in the interviews.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#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\":\"Iterative Postorder Traversal | Set 1 (Using Two Stacks)\"}]},{\"@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":"Iterative Postorder Traversal | Set 1 (Using Two Stacks)","description":"This article tried to discuss Iterative Postorder Traversal. Hope this blog helps you understand and solve the problems in the interviews.","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\/iterative-postorder-traversal-set-1-using-two-stacks\/","og_locale":"en_US","og_type":"article","og_title":"Iterative Postorder Traversal | Set 1 (Using Two Stacks)","og_description":"This article tried to discuss Iterative Postorder Traversal. Hope this blog helps you understand and solve the problems in the interviews.","og_url":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-09-13T12:11:04+00:00","article_modified_time":"2022-10-03T03:58:45+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Iterative Postorder Traversal | Set 1 (Using Two Stacks)","datePublished":"2022-09-13T12:11:04+00:00","dateModified":"2022-10-03T03:58:45+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/"},"wordCount":1277,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg","articleSection":["Stacks"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/","url":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/","name":"Iterative Postorder Traversal | Set 1 (Using Two Stacks)","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg","datePublished":"2022-09-13T12:11:04+00:00","dateModified":"2022-10-03T03:58:45+00:00","description":"This article tried to discuss Iterative Postorder Traversal. Hope this blog helps you understand and solve the problems in the interviews.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1662979185888-8%20Topic.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/iterative-postorder-traversal-set-1-using-two-stacks\/#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":"Iterative Postorder Traversal | Set 1 (Using Two Stacks)"}]},{"@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\/9618","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=9618"}],"version-history":[{"count":5,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/9618\/revisions"}],"predecessor-version":[{"id":9990,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/9618\/revisions\/9990"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=9618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=9618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=9618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}