This intermediate Leetcode problem may seem challenging but it's not once you understand the traversal and the basics of binary search trees. To solve this problem you would have to do an in-order traversal. If you're not familiar with traversing a b...
class Solution { public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { //check on the left side if(root.val > p.val && root.val > q.val) return lowestCommonAncestor(root.left, p, q); //c...
Problem statement These are two identical problems: Eolymp 4036 and 4038. The following problem statement is that of 4038, but explanation covers both problems. Given an array of integers. Create a Binary Search Tree from these numbers. If the inse...
Introduction In this blog, we will be looking into a data structure called Trees. A tree data structure is a hierarchical structure that is used to represent and organize data in a way that is easy to navigate and search. It is a collection of nodes ...