1,408 views
1 votes
1 votes

Shiva is developing two applications

Application 1 : Frequent searching is needed; but  insertions and deletions are moderate

Application 2: Frequent insertions and deletions but searching is moderate.

Which data structure Shiva should choose for application 1 and application 2 respectively?
State the reason

a) Red Black tree , AVL tree

b) AVL tree, Red Black tree

c) Either AVL tree or Red Black tree

d) Neither Red Black nor AVL Tree

2 Answers

Best answer
2 votes
2 votes

The AVL trees are more balanced compared to Red Black Trees, but they may cause more rotations during insertion and deletion. So if your application involves many frequent insertions and deletions, then Red Black trees should be preferred. And if the insertions and deletions are less frequent and search is more frequent operation, then AVL tree should be preferred over Red Black Tree.

http://www.geeksforgeeks.org/red-black-tree-set-1-introduction-2/

So Answer should be B:

selected by
0 votes
0 votes
Red black tree and AVL tree both required rotation in insertion

Both can delete node from leaf nodes, not from intermediate.

In searching both required O(log n) time to search and find a node.

So, answer is D)

Related questions

0 votes
0 votes
0 answers
2
Khursheed Bhat asked Feb 19, 2018
305 views
I was asked sometime ago in an interview draw generalised form of AVL tree that will contain all four rotations of AVL tree. I got confused I tried to explain them such n...
0 votes
0 votes
2 answers
3
Anurag_s asked Mar 4, 2016
2,867 views
Select a data structure that you have seen previously, and discuss its strengths and limitations.
1 votes
1 votes
3 answers
4
slowpoke asked May 8, 2017
794 views
Which sequence If inserted in AVL tree will cause No adjustment in tree? a) 1 2 3 4 5 ...