Tag Archive | BinarySearchTree

Convert a binary search tree to sorted list

Ques: You have given a binary search tree and you need to change this tree to link list that contains nodes in sorted order. Solution: We all know that smaller values are on left side. So we need to keep left side values at first place for sorted list. To make this happen we will […]

How to create binary search tree?

Most of the people already know the algorithm to create a binary search tree. The basic idea is to insert new value in existing binary search tree. What if the given binary search tree doesn’t exist means it is null? We will create a node with the given value and that will be the root […]