Convert Sorted Array to Binary Search Tree Leetcode Solution

Consider we are given a sorted array of integers. The goal is to build a Binary Search Tree from this array such that the tree is height-balanced. Note that a tree is said to be height-balanced if the height difference of left and right subtrees of any node in the …

Read moreConvert Sorted Array to Binary Search Tree Leetcode Solution

Find postorder traversal of BST from preorder traversal

Problem Statement The problem “Find postorder traversal of BST from preorder traversal” states that you are given preorder traversal of a binary search tree. Then using the given input find the postorder traversal. Example preorder traversal sequence: 5 2 1 3 4 7 6 8 9 1 4 3 2 …

Read moreFind postorder traversal of BST from preorder traversal

Check if a given array can represent Preorder Traversal of Binary Search Tree

The problem “Check if a given array can represent Preorder Traversal of Binary Search Tree” states that you are given a preorder traversal sequence. Now consider this sequence and find out if this sequence can represent a binary search tree or not? The expected time complexity for the solution is …

Read moreCheck if a given array can represent Preorder Traversal of Binary Search Tree

Red-Black Tree Introduction

Red Black Tree is a self-balancing binary tree. In this tree, every node is either a red node or a black node. In this Red-black Tree Introduction, we will try to cover all of its basic properties. Properties of Red-Black Tree Every node is represented as either red or black. …

Read moreRed-Black Tree Introduction

Binary Search Tree Delete Operation

Problem Statement The problem “Binary Search Tree Delete Operation” asks us to implement the delete operation for binary search tree. Delete function refers to the functionality to delete a node with a given key/data. Example Input Node to be deleted = 5 Output Approach for┬áBinary Search Tree Delete Operation So …

Read moreBinary Search Tree Delete Operation

Check if the given array can represent Level Order Traversal of Binary Search Tree

Problem Statement The problem “Check if the given array can represent Level Order Traversal of Binary Search Tree” states that you are given a level order traversal of the binary search tree. And using the level order traversal of the tree. We need to efficiently find if the level order …

Read moreCheck if the given array can represent Level Order Traversal of Binary Search Tree

Convert BST into a Min-Heap without using array

Problem Statement “Convert BST into a Min-Heap without using array” problem states that you are given a BST (binary search tree) and you need to convert it into a min-heap. The min-heap should contain all the elements in the binary search tree. The algorithm should run in linear time complexity. …

Read moreConvert BST into a Min-Heap without using array