{"id":15662,"date":"2021-08-17T07:46:03","date_gmt":"2021-08-17T02:16:03","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=15662"},"modified":"2021-08-17T07:46:06","modified_gmt":"2021-08-17T02:16:06","slug":"min-heap-python","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/min-heap-python\/","title":{"rendered":"Min Heap In Python And Its Operations"},"content":{"rendered":"\n<p>In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn What is a heap? What is min heap in python? Time complexity and applications of a heap. And at last, we will see the difference between min and <a href=\"http:\/\/www.pythonpool.com\/max-heap-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"text-decoration: underline;\">max heap.<\/span><\/a> Let us start now!<\/p>\n\n\n\n<p><strong>Min heap is one of the types of heap. Heap has two types: min heap and max heap. Heap is a data structure<\/strong>.\u00a0<strong>Generally, a heap is like a <a href=\"http:\/\/www.pythonpool.com\/level-order-traversal-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"text-decoration: underline;\">tree<\/span><\/a> that has many nodes. In a heap, the last node may be empty or filled. In a heap, there are two nodes parent node and child node. A heap is also known as a binary heap. In a max heap, a parent node is always greater than or equal to the child node. And in a min-heap, a parent node is always lesser than or equal to a child node.\u00a0<\/strong><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#What_is_min_heap_in_python\" >What is min heap in python?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Example_for_min_heap\" >Example for min heap<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Implementation_of_min_heap_in_python_using_library_functions\" >Implementation of min heap in python using library functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Representation_of_min_heap_in_python\" >Representation of min heap in python<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Parent_node_representation\" >Parent node representation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Left_child_node_representation\" >Left child node representation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Right_child_node_representation\" >Right child node representation<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#What_are_the_operations_are_available_in_min_heap\" >What are the operations are available in min heap?<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#getMin_operation\" >getMin() operation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#extractMin_operation\" >extractMin() operation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#insert_operation\" >insert() operation<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Implementation_of_min_heap_in_python_without_using_any_library_functions\" >Implementation of min heap in python without using any library functions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Applications_of_heap\" >Applications of heap<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Difference_between_min_heap_and_max_heap\" >Difference between min heap and max heap<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#FAQs_Related_to_min_heap_in_python\" >FAQs Related to min heap in python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#Trending_Right_Now\" >Trending Right Now<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-what-is-min-heap-in-python\"><span class=\"ez-toc-section\" id=\"What_is_min_heap_in_python\"><\/span>What is min heap in python?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>A min heap is a heap that contains nodes. It is one of the types of the heap. In min heap, there are two types of nodes. A parent node or root node and a child node are the types of nodes in a heap. A parent or root node should always be lesser or equal to the child node in the min heap. If the parent node is greater than a child node, then a heap becomes the <a href=\"http:\/\/www.pythonpool.com\/max-heap-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">max heap<\/a>. In min heap, the priority is always to the smallest element. It follows the ascending order.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-example-for-min-heap\"><span class=\"ez-toc-section\" id=\"Example_for_min_heap\"><\/span>Example for min heap <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"709\" height=\"564\" src=\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-35.png\" alt=\"min heap in python\" class=\"wp-image-15669\" srcset=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-35.png 709w, https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Screenshot-35-300x239.png 300w\" sizes=\"(max-width: 709px) 100vw, 709px\" \/><\/figure>\n\n\n\n<p>We can see that none of the parent nodes is greater than the child node. So this is the perfect example for min heap. If this condition is not followed, then it is not a min heap.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-implementation-of-min-heap-in-python-using-library-functions\"><span class=\"ez-toc-section\" id=\"Implementation_of_min_heap_in_python_using_library_functions\"><\/span>Implementation of min heap in python using library functions <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport heapq as heap\nl=&#x5B; ]\nheap.heappush(l,20)\nheap.heappush(l,14)\nheap.heappush(l,9)\nheap.heappush(l,90)\nheap.heappush(l,30)\nheap.heappush(l,40)\nprint(&quot;The heap is:&quot;,l)\nprint(&quot;The parent node is:&quot;,heap.heappop(l))\nprint(&quot;The child nodes are:&quot;,l)\n<\/pre><\/div>\n\n\n<p>Here we are generating a min heap using a heapq library. Using all the operations to generate a min heap. It will give the result as which is the parent and which is the child node. And also, it will give the minimum value of the heap so that we can know which is the parent node from that. <\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"h-output-1\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">The heap is: [9, 20, 14, 90, 30, 40]\nThe parent node is: 9\nThe child nodes are: [14, 20, 40, 90, 30]<\/pre>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-kilo monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Popular now<\/span><span class=\"monsterinsights-inline-popular-posts-border\" ><\/span><span class=\"monsterinsights-inline-popular-posts-border-2\" ><\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-typeerror-cant-compare-datetime-datetime-to-datetime-date\/\">[Fixed] typeerror can&#8217;t compare datetime.datetime to datetime.date<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-representation-of-min-heap-in-python\"><span class=\"ez-toc-section\" id=\"Representation_of_min_heap_in_python\"><\/span>Representation of min heap in python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We all know that the min heap is a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Binary_tree\" target=\"_blank\" rel=\"noreferrer noopener\">binary tree<\/a>. An array always represents a min heap. <strong>array[0] <\/strong>is the root element in the min heap.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-parent-node-representation\"><span class=\"ez-toc-section\" id=\"Parent_node_representation\"><\/span>Parent node representation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">array[(i -1) \/ 2] <\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-left-child-node-representation\"><span class=\"ez-toc-section\" id=\"Left_child_node_representation\"><\/span>Left child node representation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">array[(2 * i) + 1]<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-right-child-node-representation\"><span class=\"ez-toc-section\" id=\"Right_child_node_representation\"><\/span>Right child node representation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">array[(2 * i) + 1]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-what-are-the-operations-are-available-in-min-heap\"><span class=\"ez-toc-section\" id=\"What_are_the_operations_are_available_in_min_heap\"><\/span>What are the operations are available in min heap?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>getMin()<\/strong><\/li><li><strong>extractMin()<\/strong><\/li><li><strong>insert()<\/strong><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-getmin-operation\"><span class=\"ez-toc-section\" id=\"getMin_operation\"><\/span>getMin() operation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>It is useful to return the parent node of the min heap.<\/li><li><strong>O(1) <\/strong>is the time complexity of getMin().<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-extractmin-operation\"><span class=\"ez-toc-section\" id=\"extractMin_operation\"><\/span>extractMin() operation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>This operation removes the minimum element from the min heap.<\/li><li><strong>O(Log n)<\/strong>&nbsp;is the time complexity of extractMin() operation<\/li><li>extractMin() maintains the heap property after removing the parent node.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-insert-operation\"><span class=\"ez-toc-section\" id=\"insert_operation\"><\/span>insert() operation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>This operation is useful to insert a new node at the end of the heap.<\/li><li>If the new child node is smaller than a parent node then we have to exchange the parent node and the child node. <\/li><li><strong>O(Log n)<\/strong>&nbsp; is the time complexity to add the new node in the heap.<\/li><\/ul>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-delta monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-icon\" style=\"\"><svg width=\"14\" height=\"19\" viewBox=\"0 0 14 19\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M7.875 0.899463C7.875 1.59183 8.0816 2.24711 8.49479 2.8653C8.93229 3.48349 9.44271 4.06458 10.026 4.60859C10.6337 5.15259 11.2292 5.73369 11.8125 6.35188C12.4201 6.97007 12.9306 7.76135 13.3438 8.72572C13.7812 9.66537 14 10.7163 14 11.8785C14 13.832 13.3073 15.5011 11.9219 16.8858C10.5608 18.2953 8.92014 19 7 19C5.07986 19 3.42708 18.2953 2.04167 16.8858C0.680556 15.5011 0 13.832 0 11.8785C0 9.94973 0.668403 8.28062 2.00521 6.87116C2.27257 6.57443 2.58854 6.50024 2.95312 6.64861C3.31771 6.79697 3.5 7.08134 3.5 7.50171V10.6545C3.5 11.3221 3.71875 11.8908 4.15625 12.3607C4.61806 12.8305 5.16493 13.0654 5.79688 13.0654C6.45312 13.0654 7.01215 12.8428 7.47396 12.3978C7.93576 11.9279 8.16667 11.3592 8.16667 10.6916C8.16667 10.2712 8.04514 9.86318 7.80208 9.46754C7.58333 9.0719 7.31597 8.71336 7 8.3919C6.68403 8.07044 6.34375 7.73662 5.97917 7.39043C5.63889 7.04425 5.34722 6.66097 5.10417 6.2406C4.88542 5.82024 4.73958 5.35041 4.66667 4.83114C4.59375 4.31186 4.67882 3.68131 4.92188 2.93948C5.18924 2.17293 5.63889 1.33219 6.27083 0.417277C6.51389 0.0463641 6.84201 -0.0772735 7.25521 0.0463641C7.6684 0.170002 7.875 0.454368 7.875 0.899463Z\" fill=\"#EB5757\"><\/path><\/svg><\/span><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/fixed-nameerror-name-unicode-is-not-defined\/\">[Fixed] nameerror: name Unicode is not defined<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-implementation-of-min-heap-in-python-without-using-any-library-functions\"><span class=\"ez-toc-section\" id=\"Implementation_of_min_heap_in_python_without_using_any_library_functions\"><\/span>Implementation of min heap in python without using any library functions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport sys\nclass minheap: \n    def __init__(self, size):\n        self.storage=&#x5B;0]*size\n        self.size = size\n        self.heap_size = 0\n        self.Heap = &#x5B;0]*(self.size + 1)\n        self.Heap&#x5B;0] = sys.maxsize * -1\n        self.parent = 1\n        self.root=1\n    def getParentIndex(self,index):\n        return (index-1)\/\/2\n    def getLeftChildIndex(self,index):\n        return 2*index+1\n    def getRightChildIndex(self,index):\n        return 2*index+2\n    def hasParent(self,index):\n        return self.getParentIndex(index)&gt;=0\n    def insert(self,index):\n        if self.heap_size &gt;= self.size :\n            return\n        self.heap_size+= 1\n        self.Heap&#x5B;self.heap_size] = index\n        heap = self.heap_size\n        while self.Heap&#x5B;heap] &lt; self.Heap&#x5B;heap\/\/2]:\n            self.swap(heap, heap\/\/2)\n            heap = heap\/\/2\n    def swap(self, left, right):\n        self.Heap&#x5B;left], self.Heap&#x5B;right] = self.Heap&#x5B;right], self.Heap&#x5B;left]\n    def root_node(self, i):\n        if not (i &gt;= (self.heap_size\/\/2) and i &lt;= self.heap_size):\n            if (self.Heap&#x5B;i] &gt; self.Heap&#x5B;2 * i]  or  self.Heap&#x5B;i] &gt; self.Heap&#x5B;(2 * i) + 1]): \n                if self.Heap&#x5B;2 * i] &lt; self.Heap&#x5B;(2 * i) + 1]:\n                    self.swap(i, 2 * i)\n                    self.root_node(2 * i)\n                else:\n                    self.swap(i, (2 * i) + 1)\n                    self.min_heapify((2 * i) + 1)\n    def getMin(self):\n        min_value = self.Heap&#x5B;self.root]\n        self.Heap&#x5B;self.root] = self.Heap&#x5B;self.root]\n        self.size-= 1\n        self.root_node(self.root)\n        return min_value\n    def extractMin(self):\n        data=self.Heap&#x5B;1]\n        self.Heap&#x5B;1]=self.Heap&#x5B;self.size-1]\n        self.size-=1\n        return data\n    def main(self):\n       for i in range(1, (self.heap_size\/\/2)+1):\n            print(&quot;Parent Node:&quot;,str(self.Heap&#x5B;i]),&quot;Left Node:&quot;+str(self.Heap&#x5B;2 * i]),&quot;Right Node:&quot;,str(self.Heap&#x5B;2 * i + 1]))\nminHeap = minheap(11)\nminHeap.insert(70)\nminHeap.insert(8)\nminHeap.insert(80)\nminHeap.insert(3)\nminHeap.insert(90)\nminHeap.insert(30)\nminHeap.insert(23)\nminHeap.insert(45)\nminHeap.insert(100)\nprint(&quot;The Root element is &quot; ,(minHeap.getMin()))\nminHeap.main()\nprint(&quot;Remove node &quot;, minHeap.extractMin())\nminHeap.main()\n<\/pre><\/div>\n\n\n<p>We are creating a min heap using python. Using all the operations to generate a min heap. It will give the result as which is the parent and which is the child node. And also, it will give the minimum value of the heap so that we can know which is the parent node from that.<\/p>\n\n\n\n<p class=\"has-medium-font-size\" id=\"h-output\"><strong>Output <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">The Root element is  3\nParent Node: 3 Left Node:8 Right Node: 23\nParent Node: 8 Left Node:45 Right Node: 90\nParent Node: 23 Left Node:80 Right Node: 30\nParent Node: 45 Left Node:70 Right Node: 100\nRemove node  3\nParent Node: 100 Left Node:8 Right Node: 23\nParent Node: 8 Left Node:45 Right Node: 90\nParent Node: 23 Left Node:80 Right Node: 30\nParent Node: 45 Left Node:70 Right Node: 100<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-applications-of-heap\"><span class=\"ez-toc-section\" id=\"Applications_of_heap\"><\/span>Applications of heap<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>k-way merge using heap data structure.<\/li><li>Graph algorithm like prim&#8217;s algorithm using heap data structure.<\/li><li>Useful for job scheduling algorithm <\/li><li>While implementing <a href=\"http:\/\/www.pythonpool.com\/python-priority-queue\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"text-decoration: underline;\">priority queue<\/span><\/a> heap data structure is the major one.<\/li><li>Useful for order statistics<\/li><\/ul>\n\n\n<div class=\"monsterinsights-inline-popular-posts monsterinsights-inline-popular-posts-alpha monsterinsights-popular-posts-styled\" ><div class=\"monsterinsights-inline-popular-posts-text\"><span class=\"monsterinsights-inline-popular-posts-label\" >Trending<\/span><div class=\"monsterinsights-inline-popular-posts-post\"><a class=\"monsterinsights-inline-popular-posts-title\"  href=\"https:\/\/www.pythonpool.com\/solved-runtimeerror-cuda-error-invalid-device-ordinal\/\">[Solved] runtimeerror: cuda error: invalid device ordinal<\/a><\/div><\/div><\/div><p><\/p>\n\n\n<h2 class=\"wp-block-heading\" id=\"h-difference-between-min-heap-and-max-heap\"><span class=\"ez-toc-section\" id=\"Difference_between_min_heap_and_max_heap\"><\/span>Difference between min heap and max heap<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>min heap<\/strong><\/th><th><strong><a href=\"http:\/\/www.pythonpool.com\/max-heap-python\/\" target=\"_blank\" rel=\"noreferrer noopener\">max heap<\/a><\/strong><\/th><\/tr><\/thead><tbody><tr><td>The parent node is always <span style=\"text-decoration: underline\">lesser<\/span> than or equal to a child node.<\/td><td> The parent node is always <span style=\"text-decoration: underline\">greater<\/span> than or equal to a child node. <\/td><\/tr><tr><td>The parent node is always a <span style=\"text-decoration: underline\">smaller<\/span> element.<\/td><td> The parent node is always a <span style=\"text-decoration: underline\">larger<\/span> element. <\/td><\/tr><tr><td>It is in <span style=\"text-decoration: underline\">ascending<\/span> order.<\/td><td>It is in <span style=\"text-decoration: underline\">descending<\/span> order.<\/td><\/tr><tr><td>The first priority is always to the <span style=\"text-decoration: underline\">smallest<\/span> element.<\/td><td> The first priority is always to the <span style=\"text-decoration: underline\">largest<\/span> element. <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faqs-related-to-min-heap-in-python\"><span class=\"ez-toc-section\" id=\"FAQs_Related_to_min_heap_in_python\"><\/span>FAQs Related to min heap in python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1629030674688\"><strong class=\"schema-faq-question\">1. What is the major condition in the min heap?<\/strong> <p class=\"schema-faq-answer\"> In min heap, the parent node is always lesser than or equal to a child node. <\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1629030737543\"><strong class=\"schema-faq-question\">2. What are the types of the heap?<\/strong> <p class=\"schema-faq-answer\">Heap is of two types. They are min heap and max heap.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1629030774113\"><strong class=\"schema-faq-question\">3. Which element has the highest priority in the min heap?<\/strong> <p class=\"schema-faq-answer\">The smallest element in the node has the highest priority in the min heap.<\/p> <\/div> <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here we have come to the end of an article. We have learned a lot of the things about min heap in python. Heap is a data structure that has a lot of applications. We hope this article is beneficial and easy to understand.<\/p>\n\n\n<div class=\"monsterinsights-widget-popular-posts monsterinsights-widget-popular-posts-charlie monsterinsights-popular-posts-styled monsterinsights-widget-popular-posts-columns-1\"><h2 class=\"monsterinsights-widget-popular-posts-widget-title\"><span class=\"ez-toc-section\" id=\"Trending_Right_Now\"><\/span>Trending Right Now<span class=\"ez-toc-section-end\"><\/span><\/h2><ul class=\"monsterinsights-widget-popular-posts-list\"><li style=\"background-color:#EEEEEE;border-color:#CD3034;\"><a href=\"https:\/\/www.pythonpool.com\/google-api-client-python\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:17px;\">Exploring the Power of Google API Client in Python<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><li style=\"background-color:#EEEEEE;border-color:#CD3034;\"><a href=\"https:\/\/www.pythonpool.com\/python-genetic-algorithm\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:17px;\">Mastering Python Genetic Algorithms: A Complete Guide<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><li style=\"background-color:#EEEEEE;border-color:#CD3034;\"><a href=\"https:\/\/www.pythonpool.com\/aixi-python\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:17px;\">Implementation of AIXI in Python<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><li style=\"background-color:#EEEEEE;border-color:#CD3034;\"><a href=\"https:\/\/www.pythonpool.com\/counting-sort-in-python\/\"><div class=\"monsterinsights-widget-popular-posts-text\"><span class=\"monsterinsights-widget-popular-posts-title\" style=\"color:#000000;font-size:17px;\">Learn How to Implement Counting Sort in Python<\/span><div class=\"monsterinsights-widget-popular-posts-meta\" ><\/div><\/div><\/a><\/li><\/ul><\/div><p><\/p>","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn What is a heap? &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Min Heap In Python And Its Operations\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/#more-15662\" aria-label=\"More on Min Heap In Python And Its Operations\">Read more<\/a><\/p>\n","protected":false},"author":22,"featured_media":15745,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1654],"tags":[4422,4421],"class_list":["post-15662","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithm","tag-how-to-create-a-min-heap-in-python","tag-python-min-heap-implementation","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Min Heap In Python And Its Operations - Python Pool<\/title>\n<meta name=\"description\" content=\"In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn what in min heap? what is heap?\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/min-heap-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Min Heap In Python And Its Operations\" \/>\n<meta property=\"og:description\" content=\"In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn What is a heap? What is min heap in python? Time\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/min-heap-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-17T02:16:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T02:16:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Priyalakshmi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Priyalakshmi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/\"},\"author\":{\"name\":\"Priyalakshmi\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20\"},\"headline\":\"Min Heap In Python And Its Operations\",\"datePublished\":\"2021-08-17T02:16:03+00:00\",\"dateModified\":\"2021-08-17T02:16:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/\"},\"wordCount\":848,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp\",\"keywords\":[\"how to create a min heap in python\",\"python min heap implementation\"],\"articleSection\":[\"Algorithm\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/min-heap-python\/#respond\"]}]},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/\",\"url\":\"https:\/\/www.pythonpool.com\/min-heap-python\/\",\"name\":\"Min Heap In Python And Its Operations - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp\",\"datePublished\":\"2021-08-17T02:16:03+00:00\",\"dateModified\":\"2021-08-17T02:16:06+00:00\",\"description\":\"In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn what in min heap? what is heap?\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030674688\"},{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030737543\"},{\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030774113\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/min-heap-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp\",\"width\":1200,\"height\":628,\"caption\":\"Min Heap Python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Min Heap In Python And Its Operations\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20\",\"name\":\"Priyalakshmi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g\",\"caption\":\"Priyalakshmi\"}},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030674688\",\"position\":1,\"url\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030674688\",\"name\":\"1. What is the major condition in the min heap?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\" In min heap, the parent node is always lesser than or equal to a child node. \",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030737543\",\"position\":2,\"url\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030737543\",\"name\":\"2. What are the types of the heap?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Heap is of two types. They are min heap and max heap.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030774113\",\"position\":3,\"url\":\"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030774113\",\"name\":\"3. Which element has the highest priority in the min heap?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"The smallest element in the node has the highest priority in the min heap.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Min Heap In Python And Its Operations - Python Pool","description":"In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn what in min heap? what is heap?","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:\/\/www.pythonpool.com\/min-heap-python\/","og_locale":"en_US","og_type":"article","og_title":"Min Heap In Python And Its Operations","og_description":"In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn What is a heap? What is min heap in python? Time","og_url":"https:\/\/www.pythonpool.com\/min-heap-python\/","og_site_name":"Python Pool","article_published_time":"2021-08-17T02:16:03+00:00","article_modified_time":"2021-08-17T02:16:06+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp","type":"image\/webp"}],"author":"Priyalakshmi","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Priyalakshmi","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/"},"author":{"name":"Priyalakshmi","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20"},"headline":"Min Heap In Python And Its Operations","datePublished":"2021-08-17T02:16:03+00:00","dateModified":"2021-08-17T02:16:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/"},"wordCount":848,"commentCount":0,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp","keywords":["how to create a min heap in python","python min heap implementation"],"articleSection":["Algorithm"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/min-heap-python\/#respond"]}]},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/","url":"https:\/\/www.pythonpool.com\/min-heap-python\/","name":"Min Heap In Python And Its Operations - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp","datePublished":"2021-08-17T02:16:03+00:00","dateModified":"2021-08-17T02:16:06+00:00","description":"In this article, we are going to learn about min heap in python in a detailed manner. Here we will learn what in min heap? what is heap?","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030674688"},{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030737543"},{"@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030774113"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/min-heap-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/08\/Min-Heap-In-Python-And-Its-Operations.webp","width":1200,"height":628,"caption":"Min Heap Python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Min Heap In Python And Its Operations"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/83e6e22a6c461cc1a8445bb473db2f20","name":"Priyalakshmi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8f1aadb3b77a89fe5776d41fb52aec63200d0e68e92c71cb9aafac7fb4456696?s=96&d=wavatar&r=g","caption":"Priyalakshmi"}},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030674688","position":1,"url":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030674688","name":"1. What is the major condition in the min heap?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":" In min heap, the parent node is always lesser than or equal to a child node. ","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030737543","position":2,"url":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030737543","name":"2. What are the types of the heap?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Heap is of two types. They are min heap and max heap.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030774113","position":3,"url":"https:\/\/www.pythonpool.com\/min-heap-python\/#faq-question-1629030774113","name":"3. Which element has the highest priority in the min heap?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"The smallest element in the node has the highest priority in the min heap.","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/15662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=15662"}],"version-history":[{"count":51,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/15662\/revisions"}],"predecessor-version":[{"id":15749,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/15662\/revisions\/15749"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/15745"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=15662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=15662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=15662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}