Deprecated: Implicit conversion from float-string "1546111637.268" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1546111637.268" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1546111637.268" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1546111637.268" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1546111637.268" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1564144607.682" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1564144607.682" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1564144607.682" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1564144607.682" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1564144607.682" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1566462282.093" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1566462282.093" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1566462282.093" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1566462282.093" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1566462282.093" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1595795835.899" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1595795835.899" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1595795835.899" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1595795835.899" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1595795835.899" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1579396557.337" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1579396557.337" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1579396557.337" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1579396557.337" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1579396557.337" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1662108659.349" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1662108659.349" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1662108659.349" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1662108659.349" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1662108659.349" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1667665759.090" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1667665759.090" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1667665759.090" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1667665759.090" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1667665759.090" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1667713641.557" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1667713641.557" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1667713641.557" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1667713641.557" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1667713641.557" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1667722900.215" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1667722900.215" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1667722900.215" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1667722900.215" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1667722900.215" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1667877465.229" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1667877465.229" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1667877465.229" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1667877465.229" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1667877465.229" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
GATE CSE 1997 | Question: 16 / GATE Overflow for GATE CSE
edited by
4,971 views
22 votes
22 votes

A size-balanced binary tree is a binary tree in which for every node the difference between the number of nodes in the left and right subtree is at most $1$. The distance of a node from the root is the length of the path from the root to the node. The height of a binary tree is the maximum distance of a leaf node from the root.

  1. Prove, by using induction on h, that a size-balance binary tree of height $h$ contains at least $2^h$ nodes.

  2. In a size-balanced binary tree of height $h \geqslant  1$, how many nodes are at distance $h-1$ from the root? Write only the answer without any explanations.

edited by

3 Answers

Best answer
24 votes
24 votes
  1. Prove, by using induction on $h$, that a size-balanced binary tree of height h contains at least $2^h$ nodes.
    When
    $h = 0$ ……… least no. of nodes $= 2 ^ 0 = 1$
    $h = 1$ ……… least no. of nodes $= 2 ^ 1 = 2$
    $h = 2$ ……… least no. of nodes $= 2 ^ 2 = 4$
    Assume that the rule is true for $h = k$
    Then the min no. of nodes $= 2 ^ k$ nodes
    If we increase the height by $1$ by adding a node, we must also add nodes to fill the (max level $-1$) level.
    This would mean doubling the nodes
    Thus $2^{k+1}$
    Hence, proved
     
  2. In a size-balanced binary tree of height $h \geq 1$, how many nodes are at distance $h-1$ from the root? Write only the answer
    without any explanation
    $2^{h-1}$
edited by
9 votes
9 votes

(a) recursive equation for nodes at height h,

N(h)= nodes in LST + 1 + nodes in RST

N(h)= N(h-1) + 1 + { N(h-1) - 1 }

N(h)= 2N(h-1) ; when h>=2

       by intution N(0)=1, N(1)=2 

by solving above equation by back substitution (termination condition, h-k=1) we will get 

                                                              N(h)= 2h

(b)  for h<=1

at h=1,  N(1)=2

at h=0, N(0)= 1 

edited by

Related questions

1.2k
views
0 answers
1 votes
Mamta Satywali asked Mar 14, 2018
1,155 views
In this GATE ques- Part a) For Size balanced tree the recurrence (max height) is T(h)=T(h-1) +T(h-2) +1, solving which we getT(0)=1, T(1)=2,T(2)=1+2+1=4, T(3)=4+2+1=7Here...
3.9k
views
4 answers
19 votes
Kathleen asked Sep 29, 2014
3,892 views
Let $R$ be a reflexive and transitive relation on a set $A$. Define a new relation $E$ on $A$ as$E=\{(a, b) \mid (a, b) \in R \text{ and } (b, a) \in R \}$Prove that $E$ ...
4.7k
views
3 answers
23 votes
Kathleen asked Sep 29, 2014
4,688 views
Consider the following piece of 'C' code fragment that removes duplicates from an ordered list of integers.Node *remove-duplicates (Node* head, int *j) { Node *t1, *t2; ...
5.0k
views
2 answers
28 votes
Kathleen asked Sep 29, 2014
5,001 views
An array $A$ contains $n \geq 1$ positive integers in the locations $A , A , \dots A[n]$. The following program fragment prints the length of a shortest sequence of conse...
Total PHP MySQL Other RAM
Time (ms) % Time (ms) % File count Time (ms) % Query count Time (ms) % Amount %
Setup 7.1 4% 5.1 3% 72 2.2 1% 2 0.0 0% 569k 40%
Control 18.3 11% 2.2 1% 5 16.5 10% 12 0.0 0% 323k 22%
View 5.1 3% 5.1 3% 12 0.0 0% 0 0.0 0% 166k 11%
Theme 115.2 75% 5.6 3% 15 109.7 71% 3 0.0 0% 360k 25%
Stats 7.7 5% 0.1 0% 0 7.6 4% 1 0.0 0% 0k 0%
Total 153.3 100% 18.0 11% 104 136.1 88% 18 0.0 0% 1422k 100%