Search code examples
c++data-structureslinked-listbinary-search-treerecursive-datastructures

How to improve the efficiency of search operation for BST?


Suppose as a computer programmer, you have been assigned a task to develop a program to store the sorted data in ascending order. Initially, you have used linked list data structure to store the data but search operation was time consuming then you decided to use BST (Binary Search Tree) but retrieval efficiency is not improved. In such situation, How can you improve the efficiency of the search operation for BST? Justify your answer with solid reason.


Solution

  • For such type of data which is in ascending order, You can convert the given BST into a height Balanced binary tree or Self balancing binary tree. That will improve the search operation on the new BST. Infact, Self Balancing binary trees are used to construct and maintain ordered lists such as priority queues.