in DS retagged by
1,637 views
1 vote
1 vote

Which of the following need not be a binary tree?

  1. Search tree
  2. Heap
  3. AVL tree
  4. B tree
in DS retagged by
by
1.6k views

17 Comments

Heap need not be always binary , it may be $d_{ary}$ heap
1
1
A B-Tree is not a binary tree , it may be n-ary tree
1
1
moved by
(b) B-Tree
2
2
edited by
Heap needn't be a binary tree always. The only requirement to be a heap is it should be a complete tree.
0
0
@smsubham : your argument is valid $\text{iff}$ Heap is a $\text{binary heap}$
0
0

sourav. 

By mistake added binary in 2nd sentence. Check now.

Heap Variants:

  • 2-3 heap
  • Binary heap
  • Many many others
0
0

The only requirement to be a heap is it should be a complete tree.

also $\text{Almost complete binary tree}$

0
0
What is the difference between complete and almost complete binary tree?
0
0
Saw that before asking, But things aren't clear there. Can you give an example which is complete BT but not almost complete BT and vice versa?
0
0

if last level of the tree are completely fill then it is complete binary tree 

and if 2nd last level are completely filled but the last level is not completely filled then it is almost complete binary tree

1
1

So definition and examples given here are wrong i suppose.

https://www.geeksforgeeks.org/binary-tree-set-3-types-of-binary-tree/

According to it: 

Complete Binary Tree: A Binary Tree is complete Binary Tree if all levels are completely filled except possibly the last level and the last level has all keys as left as possible

Following are examples of Complete Binary Trees

               18
           /       \  
         15         30  
        /  \        /  \
      40    50    100   40


               18
           /       \  
         15         30  
        /  \        /  \
      40    50    100   40
     /  \   /
    8   7  9 
0
0
first one is complete and other is almost complete  binary tree
1
1
If there is another option(e) Search Tree then can "Option (e) - Search Tree" also be an answer? Because search tree can be a "Ternary search tree" and need not to be binary.
0
0
What is the answer given..

is it both a and b
0
0
Option D
1
1

@haralk10 see my answer, even A and B are correct.

0
0

5 Answers

4 votes
4 votes

Will be both Heap and B tree.

Heaps
Definition: A heap is a specialized tree-based data structure that satisfied the heap property:
  • if B is a child node of A, then key(A) ≥ key(B). This implies that an element with the greatest key is always in the root node, and so such a heap is sometimes called a max-heap. Of course, there's also a min-heap.

Variants:

  • 2-3 heap
  • Binary Heap
  • Many many others

Binary heap storage rules  -- A heap implemented with a binary tree in which the following two rules are followed:

  • The element contained by each node is greater than or equal to the elements of that node's children.
  • The tree is a complete binary tree.

So heap needn't be binary always.

AVL tree is BST with balancing factor.

Source: https://www.cpp.edu/~ftang/courses/CS241/notes/heap.htm

2 Comments

@smshubham : you are half correct.

you have wriiten that $\text{B tree}$ are not necessarily binary .It is correct.where is your explanation?
0
0

@sourav

The B-tree is a generalization of a binary search tree in that a node can have more than two children

Source: https://en.wikipedia.org/wiki/B-tree

0
0
1 vote
1 vote
B tree...................... B trees need not be the binary tree. B trees may have more than 2 children....

order of B tree is max. no. of children a node can have..

4 Comments

let me see a binary tree with more than 2 children!!!!

0
0
binary tree always have  2 children...but B trees need not be only 2 children it may have more than 2 children.....
2
2

Priyanka Agarwal  yes you are right

0
0
I don't think this is correct. Check my answer.
0
0
1 vote
1 vote
Search Tree => Can be Binary or n ary (Even B+ tree, AVL Tree are search tree only)

Heap => Can be binary as well as n ary

AVL Tree => Also a search tree, usually its binary. (didn't get any reference saying otherwise)

B Tree => Not necessarily a binary tree.

So A,B,D need not be a binary tree.

But in exam one can select D, as that maybe most appropriate "as per examiner".
0 votes
0 votes
B-Tree is the answer as it can bee m-ary .

heap is almost complete binary tree and AVL tree is height balanced binary tree.
Answer:

Related questions