Binary search tree is a type of data structure which has various applications in computer science. One of the important application of binary search tree is sorting of data elements. In this method of sorting all the elements are arranged according to the binary search tree then in-order traversal will give all elements in ascending order. Example, to sorting 10 numbers 26, 5, 37, 1, 61, 11, 59, 48, 19 in ascending order we use following steps:
1. Arrange all the elements in binary search tree
2. find inorder traversal of binary search tree.
Inorder traversal is : 1 5 11 15 19 26 37 48 59 61 which is the required result.

Following is the code for implementation of sorting using binary search tree:

binary search tree sorting output


Related Post

Leave a Reply