Given a binary tree, count all subtrees in it such that every node in the subtree have same value. Get great deals at Amazon
Given a BST, find inorder successor of a given key in it. If the given key do not lie in the BST, then return the next greater key (if any) present in the BST.
Given a binary tree, find maximum difference between a node and its descendants in it.
Given a binary tree, write an efficient algorithm to print right view of given binary tree.
Given a binary tree, write an iterative algorithm to print leaf to root path for every leaf node of binary tree. Use of Recursion is prohibited.
Given a binary tree, write an efficient algorithm to compute maximum width of it.
Given an array A which represents a binary tree such that the parent-child relationship is defined by (A[i], i) for every index i in the array A, build binary tree out of it. The value of root node will be i if -1 is present at index i in the array. It may be assumed …
Given a binary tree, write an efficient algorithm to invert binary tree.
Given a normal binary tree, convert it to Left-child right-sibling (LC-RS) binary tree.
Given an ancestor matrix, whose cell (i, j) has value true if i is ancestor of j in a binary tree, construct a binary tree from it where binary tree nodes are labelled from 0 to n-1 where n is the size of the ancestor matrix.
Write an algorithm to compute the height of a binary tree with leaf nodes forming a circular doubly linked list where the left and right pointers of the leaf node will act as a previous and next pointer of circular doubly linked list respectively. For example, consider below binary tree. The leaf nodes are …
Huffman Coding (also known as Huffman Encoding) is a algorithm for doing data compression and it forms the basic idea behind file compression. This post talks about fixed length and variable length encoding, uniquely decodable codes, prefix rules and construction of Huffman Tree.