{"id":10033,"date":"2022-09-28T10:08:08","date_gmt":"2022-09-28T10:08:08","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=10033"},"modified":"2022-10-10T09:36:58","modified_gmt":"2022-10-10T09:36:58","slug":"check-mirror-in-n-ary-tree","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/","title":{"rendered":"Check Mirror in N-ary Tree"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg\" alt=\"\" \/><\/p>\n<h3>Problem Statement:<\/h3>\n<p>You are given 2 N-ary trees. You have to determine whether the 2 trees are mirror images of each other or not. You have to print \u201ctrue\u201d if they are mirror images of each other and \u201cfalse\u201d otherwise.<\/p>\n<h3>Example:<\/h3>\n<p>Consider the two trees shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185075670-1-01.png\" alt=\"\" \/><\/p>\n<p>The two trees shown in the image are mirror images of each other. A mirror image means that each corresponding node in both the trees should have the same number of children and the order of children should be reversed. The order of children is reversed so that the node closest to the imaginary mirror in between them can remain closest in both the trees and the farther one remains farther.<\/p>\n<p>As shown in the trees above, node 90 is closest to the mirror in the first tree and so is the case with the second tree as well. (The property of the mirror that the object in the mirror image is at an equal distance from the actual object from the mirror is followed.)<\/p>\n<h3>Approach<\/h3>\n<p>We will use a HashMap of Stacks to solve this problem. We will traverse the first tree completely and for each node in the first tree, we will add that node to the hashmap and corresponding to it, a <a href=\"https:\/\/prepbytes.com\/blog\/category\/stacks\/\">Stack<\/a> containing the nodes connected to it.<\/p>\n<p>For instance, consider the tree T1 shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185090232-1-02.png\" alt=\"\" \/><\/p>\n<p>So, currently, we are at node 10 or the root node of T1. We add the node to the HashMap and we also have a stack against the node value in the hashmap in which, we add all the children of Node 10 as shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185102438-1-03.png\" alt=\"\" \/><\/p>\n<p>Next, we move to Node 20 by traversing the tree in preorder. <\/p>\n<p>So, 20 is added to the HashMap with the Stack of its children.<\/p>\n<p>![]()<br \/>\nNext, we move to Node 50. Here, we don&#8217;t have any children. Hence, the stack will be empty.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185119397-1-04.png\" alt=\"\" \/><br \/>\nThe same will be the case with 60.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185166485-1-05.png\" alt=\"\" \/><\/p>\n<p>So, this is what we have to do for the entire tree T1. <\/p>\n<p>Now, how will we check whether the trees T1 and T2 are mirror images or not? <\/p>\n<p>So, consider that we have filled the HashMap by traversing the tree T1 and we are now at tree T2.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185181548-1-06.png\" alt=\"\" \/><\/p>\n<p>Now, we are at Node 10 of the tree T2. We will go to Node 10 in the HashMap. If the HashMap does not contain node 10, the trees are not mirrored images of each other.<\/p>\n<p>However, in this case, the HashMap contains node 10. So, we now traverse through the children of Node 10 in T2 and the stack corresponding to node 10 in the HashMap. <\/p>\n<p>If the child of node 10 in T2 is present at the top of the Stack in the HashMap, we pop the value from the stack. If it is not present at the top of the stack, the trees are not mirrored images of each other.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185208151-1-07.png\" alt=\"\" \/><\/p>\n<p>For instance, in the image shown above, we see that when we were at 40, 40 was at the top of the stack. So, we popped it. Then, we came to node 30, and 30 was present at the top of the stack. So, we popped it as well. Similarly, we came to node 20 and it was present at the top of the stack. So, we popped it as well. <\/p>\n<p>When we completed visiting the children of node 10, the stack also became empty. If the stack is not empty, the trees are not mirrored images of each other. If it is empty, perform the above operations for the next node.<\/p>\n<p>Similarly, we have to do the same for the entire tree T2. In this case, we will find that T1 and T2 are mirror images of each other.<\/p>\n<p>Now that we have understood this approach, let us write the code for the same.<\/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_10034 {\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_10034 .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_10034 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_10034 .wpsm_nav-tabs > li.active > a, #tab_container_10034 .wpsm_nav-tabs > li.active > a:hover, #tab_container_10034 .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_10034 .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_10034 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_10034 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_10034 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_10034 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_10034 .wpsm_nav-tabs > li > a:hover , #tab_container_10034 .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_10034 .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_10034 .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_10034 .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_10034 .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_10034 .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_10034 .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_10034 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10034 .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_10034 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10034 .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_10034 .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_10034\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_10034\">\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_10034_1\" aria-controls=\"tabs_desc_10034_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_10034_2\" aria-controls=\"tabs_desc_10034_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_10034\">\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_10034_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\nint checkMirrorTree(int M, int N, int u1[ ],\r\n\t\t\t\t\tint v1[ ] , int u2[], int v2[])\r\n\t{\r\n\t\t\r\n\t\tunordered_map&lt;int , stack&lt;int&gt;&gt;mp;\r\n\r\n\t\tfor (int i = 0 ; i &lt; N ; i++ )\r\n\t\t{\r\n\t\t    mp[u1[i]].push(v1[i]);\r\n\t\t}\r\n\t\t\r\n    \r\n\t\tfor (int i = 0 ; i &lt; N ; i++)\r\n\t\t{\r\n\t\t\tif(mp[u2[i]].top() != v2[i])\r\n\t\t\t\treturn 0;\r\n\t\t\tmp[u2[i]].pop();\r\n\t\t}\r\n\r\n\t\treturn 1;\r\n\t}\r\n\r\nint main()\r\n{\r\n\tint M = 7, N = 6;\r\n\t\r\n\tint u1[] = { 1, 1, 1, 10, 10, 10 };\r\n\tint v1[] = { 10, 7, 3, 4, 5, 6 };\r\n\r\n\tint u2[] = { 1, 1, 1, 10, 10, 10 };\r\n\tint v2[] = { 3, 7, 10, 6, 5, 4 };\r\n\r\n\tif(checkMirrorTree(M, N, u1, v1, u2, v2))\r\n\tcout&lt;&lt;&quot;Yes, the trees are mirror&quot;;\r\n\telse\r\n\tcout&lt;&lt;&quot;No, they are not mirror&quot;;\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_10034_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\r\n\tstatic boolean checkMirrorTree(int M, int N, int[] u1, int[] v1, int[] u2, int[] v2)\r\n\t{\r\n\t\t\r\n\r\n\t\tHashMap&lt;Integer, Stack&lt;Integer&gt;&gt; mp = new HashMap&lt;&gt;();\r\n\t\r\n\t\tfor (int i = 0 ; i &lt; N ; i++ )\r\n\t\t{\r\n              if(!mp.containsKey(u1[i]))\r\n              {\r\n                mp.put(u1[i], new Stack&lt;Integer&gt;());\r\n              }\r\n              else{\r\n                mp.get(u1[i]).push(v1[i]);\r\n              }\r\n\t\t}\r\n\t\t\r\n\t\tfor (int i = 0 ; i &lt; N ; i++)\r\n\t\t{\r\n\t\t\tif(mp.containsKey(u2[i]) &amp;&amp; mp.get(u2[i]).size() &gt; 0)\r\n\t\t\t{\r\n\t\t\t\tif(mp.get(u2[i]).peek() != v2[i])\r\n\t\t\t\treturn false;\r\n\t\t\t\tmp.get(u2[i]).pop();\r\n\t\t\t}\r\n\t\t}\r\n\t\r\n\t\treturn true;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tint M = 7, N = 6;\r\n\t\r\n        int[] u1 = { 1, 1, 1, 10, 10, 10 };\r\n\t\tint[] v1 = { 10, 7, 3, 4, 5, 6 };\r\n\t\t\r\n\t\tint[] u2 = { 1, 1, 1, 10, 10, 10 };\r\n\t\tint[] v2 = { 3, 7, 10, 6, 5, 4 };\r\n\t\r\n\t\tif(checkMirrorTree(M, N, u1, v1, u2, v2))\r\n\t\tSystem.out.print(&quot;Yes, they are mirror&quot;);\r\n\t\telse\r\n\t\tSystem.out.print(&quot;No, they are not mirror&quot;);\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_10034 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_10034 a\"),jQuery(\"#tab-content_10034\"));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> The time complexity of this solution will be O(N) as we are traversing both trees once.<\/p>\n<p><strong>Space Complexity (Auxiliary Space):<\/strong> The space complexity is O(N) as we have used a HashMap that will contain all the N nodes of the tree T1. <\/p>\n<p>So, the time complexity is O(N). However, using a HashMap is not a safe option. Usually, the HashMap can find a node in O(1) time. However, the worst case of HashMap for finding a key-value pair is O(N) because of excessive collisions. <\/p>\n<p>So, in order to avoid this worst case, we can use another approach<\/p>\n<h3>Approach-2<\/h3>\n<p>We will create 2 lists. One lists will contain stacks and one will contain queues. We iterate over the first tree and fill the list of stacks as shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185224060-1-08.png\" alt=\"\" \/><\/p>\n<p>Now, we iterate over the second tree and fill the list of queues as shown below.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185235570-1-09.png\" alt=\"\" \/><\/p>\n<p>Now, we will traverse both the lists corresponding to each node, we will pop an element from the stack and the queue. If they are equal, we continue else they are not mirror images of each other.<\/p>\n<p>So, let us write the code for the above procedure too.<\/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_10035 {\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_10035 .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_10035 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_10035 .wpsm_nav-tabs > li.active > a, #tab_container_10035 .wpsm_nav-tabs > li.active > a:hover, #tab_container_10035 .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_10035 .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_10035 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_10035 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_10035 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_10035 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_10035 .wpsm_nav-tabs > li > a:hover , #tab_container_10035 .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_10035 .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_10035 .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_10035 .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_10035 .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_10035 .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_10035 .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_10035 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10035 .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_10035 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_10035 .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_10035 .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_10035\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_10035\">\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_10035_1\" aria-controls=\"tabs_desc_10035_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-laptop\"><\/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_10035\">\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_10035_1\">\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.io.*;\r\nimport java.util.*;\r\n\r\nclass Main {\r\n\r\n\tstatic int checkMirrorTree(int n, int e, int[] A, int[] B) {\r\n\r\n\t\tList&lt;Stack&lt;Integer&gt;&gt; s = new ArrayList&lt;&gt;();\r\n\t\tList&lt;Queue&lt;Integer&gt;&gt; q = new ArrayList&lt;&gt;();\r\n\r\n\t\tfor (int i = 0; i &lt;= n; i++) {\r\n\t\t\ts.add(new Stack&lt;&gt;());\r\n\t\t\tQueue&lt;Integer&gt; queue = new LinkedList&lt;&gt;();\r\n\t\t\tq.add(queue);\r\n\t\t}\r\n\r\n\t\tfor (int i = 0; i &lt; 2 * e; i += 2) {\r\n\t\t\ts.get(A[i]).push(A[i + 1]);\r\n\t\t\tq.get(B[i]).add(B[i + 1]);\r\n\t\t}\r\n\r\n\t\tfor (int i = 1; i &lt;= n; i++) {\r\n\t\t\twhile (!s.get(i).isEmpty() &amp;&amp; !q.get(i).isEmpty()) {\r\n\t\t\t\tint a = s.get(i).pop();\r\n\t\t\t\tint b = q.get(i).poll();\r\n\r\n\t\t\t\tif (a != b) {\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn 1;\r\n\t}\r\n\r\n\tpublic static void main (String[] args) {\r\n\t\tint n = 3;\r\n\t\tint e = 2;\r\n\t\tint A[] = { 1, 2, 1, 3 };\r\n\t\tint B[] = { 1, 3, 1, 2 };\r\n\r\n\t\tif (checkMirrorTree(n, e, A, B) == 1) {\r\n\t\t\tSystem.out.println(&quot;Yes, the trees are mirror&quot;);\r\n\t\t} else {\r\n\t\t\tSystem.out.println(&quot;No, the trees are not mirror&quot;);\r\n\t\t}\r\n\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_10035 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_10035 a\"),jQuery(\"#tab-content_10035\"));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> The time complexity of this solution will be O(N) as we are traversing both trees once.<\/p>\n<p><strong>Space Complexity (Auxiliary Space):<\/strong> The space complexity is O(N) as we have used 2 lists that will contain all the N nodes of the tree T1 and tree T2 respectively.<\/p>\n<p>We tried to discuss Check Mirror in N-ary Tree. We hope this article gives you a better understanding of Check Mirror in N-ary Tree. <a href=\"https:\/\/www.prepbytes.com\/\" title=\"PrepBytes\">PrepBytes<\/a> also provides a good collection of <a href=\"https:\/\/www.prepbytes.com\/prepbytes-courses\" title=\"Foundation Courses\">Foundation Courses<\/a> that can help you enhance your coding skills. Want to make sure you ace the interview in one go? Join our <a href=\"https:\/\/www.prepbytes.com\/placement-preparation-program\" title=\"Placement Program\">Placement Program<\/a> which will help you get prepared and land your dream job at MNCs. Mentors of Prepbytes are highly experienced and can provide you with basic, in-depth subject knowledge for better understanding.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Statement: You are given 2 N-ary trees. You have to determine whether the 2 trees are mirror images of each other or not. You have to print \u201ctrue\u201d if they are mirror images of each other and \u201cfalse\u201d otherwise. Example: Consider the two trees shown below. The two trees shown in the image are [&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":[153],"tags":[],"class_list":["post-10033","post","type-post","status-publish","format-standard","hentry","category-tree"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Check Mirror in N-ary Tree | Trees | PrepBytes Blog<\/title>\n<meta name=\"description\" content=\"We tried to discuss Check Mirror in N-ary Tree. We hope this article gives you a better understanding of Check Mirror in N-ary Tree.\" \/>\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\/check-mirror-in-n-ary-tree\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Check Mirror in N-ary Tree | Trees | PrepBytes Blog\" \/>\n<meta property=\"og:description\" content=\"We tried to discuss Check Mirror in N-ary Tree. We hope this article gives you a better understanding of Check Mirror in N-ary Tree.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/\" \/>\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-28T10:08:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-10T09:36:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Check Mirror in N-ary Tree\",\"datePublished\":\"2022-09-28T10:08:08+00:00\",\"dateModified\":\"2022-10-10T09:36:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/\"},\"wordCount\":968,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg\",\"articleSection\":[\"Trees\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/\",\"name\":\"Check Mirror in N-ary Tree | Trees | PrepBytes Blog\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg\",\"datePublished\":\"2022-09-28T10:08:08+00:00\",\"dateModified\":\"2022-10-10T09:36:58+00:00\",\"description\":\"We tried to discuss Check Mirror in N-ary Tree. We hope this article gives you a better understanding of Check Mirror in N-ary Tree.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Trees\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/tree\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Check Mirror in N-ary Tree\"}]},{\"@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":"Check Mirror in N-ary Tree | Trees | PrepBytes Blog","description":"We tried to discuss Check Mirror in N-ary Tree. We hope this article gives you a better understanding of Check Mirror in N-ary Tree.","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\/check-mirror-in-n-ary-tree\/","og_locale":"en_US","og_type":"article","og_title":"Check Mirror in N-ary Tree | Trees | PrepBytes Blog","og_description":"We tried to discuss Check Mirror in N-ary Tree. We hope this article gives you a better understanding of Check Mirror in N-ary Tree.","og_url":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2022-09-28T10:08:08+00:00","article_modified_time":"2022-10-10T09:36:58+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Check Mirror in N-ary Tree","datePublished":"2022-09-28T10:08:08+00:00","dateModified":"2022-10-10T09:36:58+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/"},"wordCount":968,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg","articleSection":["Trees"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/","url":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/","name":"Check Mirror in N-ary Tree | Trees | PrepBytes Blog","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg","datePublished":"2022-09-28T10:08:08+00:00","dateModified":"2022-10-10T09:36:58+00:00","description":"We tried to discuss Check Mirror in N-ary Tree. We hope this article gives you a better understanding of Check Mirror in N-ary Tree.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1664185251467-Topic.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/check-mirror-in-n-ary-tree\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Trees","item":"https:\/\/prepbytes.com\/blog\/category\/tree\/"},{"@type":"ListItem","position":3,"name":"Check Mirror in N-ary Tree"}]},{"@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\/10033","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=10033"}],"version-history":[{"count":3,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10033\/revisions"}],"predecessor-version":[{"id":10187,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/10033\/revisions\/10187"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=10033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=10033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=10033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}