GATE CSE
First time here? Checkout the FAQ!
x
+3 votes
668 views

In which tree, for every node the height of its left subtree and right subtree differ almost by 1?

  1. Binary Search Tree
  2. AVL Tree
  3. Threaded Binary Tree
  4. Complete Binary Tree
asked in DS by Veteran (92.5k points) 972 2329 3115 | 668 views

2 Answers

+7 votes

AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right sub-trees cannot be more than one for all nodes.

 

Hence,Option(B) AVL Tree is the correct choice.

 

answered by Veteran (35.3k points) 11 49 231
+1 vote
Although by definition of AVL tree(or height balance tree) right ans is B .But i think same property also holds for complete binary tree

as from a full binary tree if we start removing elements from  the right most child we will always get a tree which is height balanced

any expert comments if i am wrong
answered by Veteran (46.9k points) 61 295 641

Although  the fact you given here for complete binary tree is likely to AVL tree, but the purpose of self balancing binary search tree is different than complete binary tree.

In complete binary no  such properties(i.e. every node the height of its left subtree and right subtree differ almost by 1) holds.

Also self balancing binary search tree is used for other data structure such as priority queue.Self-balancing binary search trees can be used  to construct and maintain ordered lists

These are available Self balancing binary search tree..

Arjun sir can give more clarity here.

In a complete binary tree the property does hold :O
@Arjun Sir i mean here by definition no such rule for CBT.Because

A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.

But this property((i.e. every node the height of its left subtree and right subtree differ almost by 1) comes automatically in a complete binary tree.

Am i rt ?
@Arjun Sir ..In a complete binary tree why the above property does not hold  .. ?
I mean it does hold, there is not a counter example rt?
ohh sorry .. my bad .. then D should also be right option .. right sir ??
yes, though B is a safer choice.
Answer:

Related questions

+2 votes
1 answer
2
asked in DS by Purple Loyal (4.1k points) 17 68 129 | 136 views
+2 votes
1 answer
3
asked in DS by thor Boss (9.1k points) 4 64 210 | 129 views


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
Top Users Oct 2017
  1. Arjun

    23398 Points

  2. Bikram

    17078 Points

  3. Habibkhan

    8280 Points

  4. srestha

    6300 Points

  5. Debashish Deka

    5438 Points

  6. jothee

    4978 Points

  7. Sachin Mittal 1

    4772 Points

  8. joshi_nitish

    4352 Points

  9. sushmita

    3970 Points

  10. Rishi yadav

    3804 Points


Recent Badges

Regular Rishabh Gupta 2
Popular Question Sunil8860
Reader Rajesh Veeranki 2
Notable Question rahul sharma 5
Commentator Shivam Chauhan
Notable Question set2018
Nice Comment srestha
Notable Question set2018
Regular Shankar Jha
Popular Question Shubhanshu
27,325 questions
35,177 answers
84,123 comments
33,280 users