{"id":160350,"date":"2023-09-26T13:36:24","date_gmt":"2023-09-26T08:06:24","guid":{"rendered":"https:\/\/www.gkseries.com\/blog\/?p=160350"},"modified":"2023-09-26T13:36:26","modified_gmt":"2023-09-26T08:06:26","slug":"the-number-of-possible-min-heaps-containing-each-value-from-1-2-3-4-5-6-7exactly-once-is","status":"publish","type":"post","link":"https:\/\/www.gkseries.com\/blog\/the-number-of-possible-min-heaps-containing-each-value-from-1-2-3-4-5-6-7exactly-once-is\/","title":{"rendered":"The\u00a0number\u00a0of\u00a0possible\u00a0min-heaps\u00a0containing\u00a0each\u00a0value\u00a0from\u00a0{1, 2, 3, 4, 5, 6, 7}exactly\u00a0once\u00a0is"},"content":{"rendered":"\n<p>Q. The\u00a0number\u00a0of\u00a0possible\u00a0min-heaps\u00a0containing\u00a0each\u00a0value\u00a0from\u00a0{1, 2, 3, 4, 5, 6, 7}exactly\u00a0once\u00a0is <\/p>\n\n\n\n<p>Ans: 80<\/p>\n\n\n\n<p>Sol:<\/p>\n\n\n\n<p>Set minimum element as root (i.e 1), now 6 are remaining and left subtree will have 3 elements, each left subtree combination can be permuted in 2! ways. Total ways to design min-heap with 7-elements =<\/p>\n\n\n\n<p>^6C_3 *2! * 2! = 20*2*2 = 80<\/p>\n\n\n\n<p>Alternative approach \u2013<\/p>\n\n\n\n<p>Total number of min or max heap tree with 1 to N elements are using recurrence relation:<\/p>\n\n\n\n<p>T(N) =(N-1)Ck * T(k) * T(N-k-1),<\/p>\n\n\n\n<p>where k = number of nodes on left subtree<\/p>\n\n\n\n<p>T(1) = 1<\/p>\n\n\n\n<p>T(2) = 1<\/p>\n\n\n\n<p>T(3) = 2<\/p>\n\n\n\n<p>T(4) = 3C2 * T(2) * T(1) = 3<\/p>\n\n\n\n<p>T(5) = 4C3 * T(3) * T(1) = 8<\/p>\n\n\n\n<p>T(6) = 5C3 * T(3) * T(2) = 20<\/p>\n\n\n\n<p>T(7) = 6C3 * T(3) * T(3) = 80<\/p>\n\n\n\n<p>So, answer is 80.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Q. The\u00a0number\u00a0of\u00a0possible\u00a0min-heaps\u00a0containing\u00a0each\u00a0value\u00a0from\u00a0{1, 2, 3, 4, 5, 6, 7}exactly\u00a0once\u00a0is Ans: 80 Sol: Set minimum element as root (i.e 1), now 6 are remaining and left subtree will have 3 elements, each left subtree combination can be permuted in 2! ways. Total ways to design min-heap with 7-elements = ^6C_3 *2! * 2! = 20*2*2 = 80 [&hellip;]<\/p>\n","protected":false},"author":419,"featured_media":160351,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[5141],"tags":[5140],"class_list":["post-160350","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gate","tag-gate-questions"],"_links":{"self":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/160350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/users\/419"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/comments?post=160350"}],"version-history":[{"count":1,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/160350\/revisions"}],"predecessor-version":[{"id":160352,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/posts\/160350\/revisions\/160352"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/media\/160351"}],"wp:attachment":[{"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/media?parent=160350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/categories?post=160350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gkseries.com\/blog\/wp-json\/wp\/v2\/tags?post=160350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}