The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
111 views

Please explain the logic behind this shortcut and when to be used?

closed as a duplicate of: Madeaeasy
asked in Algorithms by (435 points)
closed ago by | 111 views
0
From my observation :-  this is what they are doing.. total ways to arrange 9 numbers = 9!

For denominator, start from root node, visit every node and multiply the result with number of nodes present in that subtree.

Eg here for root node :- subtree has 9 nodes,

For left child of root :- subtree has 5 nodes,

For right child of root :- subtree has 3 nodes...

So on calculate for every node to obtain denominator.

You will get 9x5x3x3x1x1x1x1x1

Now Why are they doing this?
0

@Shaik Masthan @MiNiPanda

please explain this

0

I don't understand what formula they have used. But to find the no. of max(or min) heaps from n elements we follow this approach:

https://www.quora.com/How-many-Binary-heaps-can-be-made-from-N-distinct-elements

If you don't get it then I'll try to explain..

0

@MiNiPanda Pls explain your way.. Actually, I was able to figure out answer of the above question using permutations and combinations but I want to know the answer for any general case tree. 

+1

In similar way, 1st draw the structure of heap with 9 elements. There will be exactly one structure possible.

$H(9)= \binom{8}{5}H(5)H(3)$

P.S. I did for min heap but same approach will be for max heap.

@Kunal Kadian ,@himgta, @Markzuck

+1
0
If anyone wants to do fast. just watch that video it will you to solve the question only in one minute.
0

just check the beautiful explanation by KAPIL sir https://gateoverflow.in/102171

@Markzuck

Please before posting the question, should check for Duplicates.

Due to you didn't check, everyone wastes their precious time for this discussion ( due to it is already solved and discussed in very clear manner )

Related questions



Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

47,005 questions
51,325 answers
177,505 comments
66,668 users