Inorder Tree Traversal – Iterative and Recursive
Given a binary tree, write an iterative and recursive solution to traverse the tree using inorder traversal in C++, Java, and Python.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a binary tree, write an iterative and recursive solution to traverse the tree using inorder traversal in C++, Java, and Python.
Given a binary tree, write an iterative and recursive solution to traverse the tree using preorder traversal in C++, Java, and Python.
Given a binary tree, write an iterative and recursive solution to traverse the tree using postorder traversal in C++, Java, and Python.
Given a binary tree, write an efficient algorithm to determine if it can be converted into 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 the binary tree to its mirror.
Given a binary tree, write an efficient algorithm to check if it has a symmetric structure or not, i.e., left and right subtree mirror each other.
Given a binary tree, write an efficient algorithm to compute the diameter of it. Binary tree diameter equals the total number of nodes on the longest path between any two leaves in it.
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 the English alphabet’s corresponding character.
Given a binary tree, check if it is a sum tree or not. In a sum tree, each non-leaf node’s value is equal to the sum of all elements present in its left and right subtree. The value of a leaf node can be anything.
Given a binary tree, in-place convert it into its sum tree. Each node’s value is equal to the sum of all elements present in its left and right subtree in a sum tree. Consider the value of an empty node as 0.
Given a binary tree, print all cousins of a given node. Two nodes of a binary tree are cousins of each other only if they have different parents, but they have the same level.