Computer Science, asked by sainheinnkham, 1 year ago

what are the advantages and disadvantages of optimal binary search tree?

Answers

Answered by daredevil456
0

It can create an infinte seat of originalities taht are incomparable

Answered by malavikamenon0007
1

Advantages of BST are:

we can always keep the cost of insert(), delete(), lookup() to O (logN)  where N is the number of nodes in the tree - so the benefit really is that lookups can be done in logarithmic time which matters a lot when N is large.

We have an ordering of keys stored in the tree. Any time we need to traverse the increasing (or decreasing) order of keys, we just need to do the in-order (and reverse in-order) traversal on the tree.

We can implement order statistics with binary search tree - Nth smallest, Nth largest element. This is because it is possible to look at the data structure as a sorted array.

We can also do range queries - find keys between N and M (N <= M).

BST can also be used in the design of memory allocators to speed up the search of free blocks (chunks of memory), and to implement best fit algorithms where we are interested in finding the smallest free chunk with size greater than or equal to size specified in allocation request.

Disadvantages of using BST:

The main disadvantage is that we should always implement a balanced binary search tree - AVL tree, Red-Black tree, Splay tree. Otherwise the cost of operations may not be logarithmic and degenerate into a linear search on an array.

Similar questions