Category Archives: BST

Famous interview questions – binary search tree algorithm

Find ceil value of input data in binary search tree in java (DFS/Example)

Given the binary search tree, we need to find the Ceil value of given input data.
What is Ceil value ? The smallest value just greater than or equal to given input data. We have already discussed about Floor of input data in BST. The logical flow of ceil value in BST is exactly same as that floor value. Let us find Ceil value for BST shown in Fig 1.

Find K smallest element in binary search tree (BST) – DFS / example

Given a binary search tree (bst), we would like to find out K smallest element in BST. Traverse the binary search tree using depth first search (DFS) recursive algorithm. Perform InOrder binary tree traversal to find smallest K smallest element. InOrder tree traversal prints elements in sorted order. We can find out K smallest from sorted order… Read More »