Fix children-sum property in a binary tree
Write an efficient algorithm to fix the children-sum property in a given binary tree. The only operation allowed is an increment operation on the node’s value.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedWrite an efficient algorithm to fix the children-sum property in a given binary tree. The only operation allowed is an increment operation on the node’s value.
Given an array of words where no word is the prefix of another, find the shortest unique prefix to identify each word in the array uniquely.
Given two binary trees, check whether the leaf traversals of both trees are the same or not.
Construct an expression tree from a given postfix notation and print the infix notation. The binary expression tree is a binary tree whose leaves are operands, such as constants or variable names, and the other nodes contain operators.
Given a binary tree, extract all its leaves into a doubly-linked list, i.e., remove all leaf nodes from the binary tree and construct a doubly linked list out of them.
Given a level order representation of a complete binary search tree, print its elements in increasing order.
Given a binary tree, find its minimum depth. The minimum depth is the total number of nodes along the shortest path from the root node down to the nearest leaf node.
Given an undirected graph, check whether it has an Eulerian path or not. In other words, check if it is possible to construct a path that visits each edge exactly once.
An m-ary tree is a tree in which each node has no more than m children. Given an m-ary tree, write an efficient algorithm to convert the tree to its mirror.
Write an efficient algorithm to invert alternate levels of a perfect binary tree.
Write an efficient algorithm to construct a binary tree from given inorder and level-order sequence.
Write an efficient algorithm to construct a binary tree from the given inorder and postorder traversals.