Update every key in a BST to contain the sum of all greater keys
Given a binary search tree, modify it such that every key is updated to contain the sum of all greater keys present in the BST.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedGiven a binary search tree, modify it such that every key is updated to contain the sum of all greater keys present in the BST.
Given a binary tree, find the maximum difference between a node and its descendants in it.
Given a binary tree, efficiently clone of it.
Given a binary tree, write an efficient algorithm to print its right view. For example, the right view of a given binary tree is 1, 3, 6, 8.
Given a binary tree whose nodes are labeled from 0 to N-1, construct an N × N ancestor matrix. An ancestor matrix is a boolean matrix, whose cell (i, j) is true if i is an ancestor of j in the binary tree.
Given a sorted doubly linked list, in-place convert it into a height-balanced Binary Search Tree (BST). The difference between the height of the left and right subtree for every node of a height-balanced BST is never greater than 1.
Write an efficient algorithm to find postorder traversal on a given binary tree from its inorder and preorder sequence.
Given a BST and a valid range of keys, remove nodes from BST that have keys outside the valid range.
Given a binary tree, write an iterative algorithm to print the leaf-to-root path for every leaf node. Use of recursion is prohibited.
Given a binary search tree, find a pair with a given sum present in it.
Given a binary tree, write an efficient algorithm to compute the maximum number of nodes in any level in the binary tree.
Given an array representing a binary tree, such that the parent-child relationship is defined by (A[i], i) for every index i in array A, build a binary tree out of it. The root node’s value is i if -1 is present at index i in the array.