## Find Lowest Common Ancestor (LCA) of Two Nodes in a Binary Tree

Given a binary tree and two nodes x and y in it, find lowest common ancestor (LCA) of x and y in it.

Coding made easy

Given a binary tree and two nodes x and y in it, find lowest common ancestor (LCA) of x and y in it.

Given a binary tree, write iterative and recursive solution to traverse the tree using in-order traversal. Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (in-order, pre-order and post-order) or breadth-first order (level order traversal). Beyond these …

Given a binary tree, write iterative and recursive solution to traverse the tree using pre-order traversal. Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (pre-order, pre-order and pre-order) or breadth-first order (level order traversal). Beyond these …

Given a binary tree, write iterative and recursive solution to traverse the tree using post-order traversal. Unlike linked lists, one-dimensional arrays and other linear data structures, which are traversed in linear order, trees may be traversed in multiple ways in depth-first order (post-order, pre-order and post-order) or breadth-first order (level order traversal). Beyond these …

Given a binary tree, write an efficient algorithm to determine if it can be converted to another binary tree by doing any number of swaps of its right and left branches.

Given a binary tree, write an efficient algorithm to convert binary tree to its mirror.

Given a binary tree, write an efficient algorithm to check if it is symmetric binary tree or not. i.e. left subtree and right subtree are mirror images or each other.

Given a binary tree, write an efficient algorithm to compute the diameter of it. The diameter of a binary tree is equal to number of nodes on the longest path between any two leaves in it.

java.security.SecureRandom is a more secure version of java.util.Random which provides a Cryptographically Secure Pseudo-Random Number Generator (CSPRNG).

Given a device having left, right, top and bottom buttons and a OK button to enter a text from a virtual keypad having alphabets from A-Y arranged in a 5×5 grid as shown below. We need to find the shortest route in device to construct the given string if we start from the top-left position …

Given a binary tree, determine if it is a subtree of another binary tree or not. A subtree of a tree T is a tree consisting of a node in T and all of its descendants in T.

Given a set of positive numbers, find all possible combinations of words formed by replacing the continuous digits with corresponding character of English alphabet. i.e. subset {1} can be replaced by A, {2} can be replaced by B, {1, 0} can be replaced J, {2, 1} can be replaced U, etc..