Binary Search Tree Search and Insertion

Problem Statement Write an algorithm to perform searching and insertion in Binary Search Tree. So what we are going to do is insert some of the elements from input into a binary search tree. Whenever asked to search a particular element, we’ll be searching it among the elements in BST(short …

Read more

Minimum number of subsets with distinct elements

Problem Statement Suppose you have an array of integers of size n. The problem statement asks to find out the minimum number of subsets with distinct elements, that is subsets that can be formed which contain all the different/distinct elements from the array. Example arr[] = {2,4,6,2,1,4,2} 3 Explanation: {1, …

Read more

Construct BST from its given Level Order Traversal

Given the level order traversal of a Binary Search Tree, write an algorithm to construct the Binary Search Tree or BST from ITS given level order traversal. Example Input levelOrder[] = {18, 12, 20, 8, 15, 25, 5, 9, 22, 31} Output In-order : 5 8 9 12 15 18 …

Read more

Translate »