How to prove full nodes = leaves -1 for a binary tree? -


without proper mathematical proof how supposed go proving number of full nodes (a node consists of 2 children (left , right)) same number of leaves - 1? hint supposed using proof of 'structural induction', unfortunately not understand means, me out here?

mathematically, proof induction way prove statement s true values of natural number n. idea prove 1) s(1) true, 2) if s(n) true s(n+1) true, , therefore 3) s(n) true n.

in case, want prove binary trees have property. trick show binary tree (other smallest possible one) can transformed smaller binary tree, such if smaller tree has property, larger one. if can prove smallest possible binary tree has property, binary trees.

so if you're give large binary tree, what's simplest possible way make smaller?

edit: suggest take pencil , paper , try draw tree doesn't have property. start single node, root node, , add nodes 1 @ time, keeping track of number of full nodes , number of leaves. once convinced can never draw such tree, read answer again , see if makes sense.


Comments

Popular posts from this blog

r - how do you merge two data frames the best way? -

How to debug "expected android.widget.TextView but found java.lang.string" in Android? -

php - mySQL problems with this code? -