Tag Archives: binary-search-tree

Lowest Common Ancestor in a BST: GeeksforGeeks

Problem link: http://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-search-tree/

Problem Statement:
Given values of two nodes in a Binary Search Tree, write a c program to find the Lowest Common Ancestor (LCA). You may assume that both the values exist in the tree. You can assume that the nodes are present in the tree.
Continue reading

Advertisements

Check for Same BSTs from Arrays: GeeksforGeeks

Problem link: http://www.geeksforgeeks.org/check-for-identical-bsts-without-building-the-trees/

Problem Statement:
Given two arrays which represent a sequence of keys. Imagine we make a Binary Search Tree (BST) from each array. We need to tell whether two BSTs will be identical or not without actually constructing the tree.
For example, the input arrays are {2, 4, 3, 1} and {2, 1, 4, 3} will construct the same tree
Continue reading