##
Maximum Path Sum in a Binary Tree
August 21, 2015

Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example: Input: Root of below tree

August 21, 2015

Given a binary tree, find the maximum path sum. The path may start and end at any node in the tree. Example: Input: Root of below tree

August 13, 2015

Expression tree is a binary tree in which each internal node corresponds to operator and each leaf node corresponds to operand so for example expression tree for 3 + ((5+9)*2) would be:

July 17, 2015

In this article, first count of possible BST (Binary Search Trees)s is discussed, then construction of all possible BSTs. How many structurally unique BSTs for keys from 1..N?

July 16, 2015

Given a Binary Search Tree (BST) and a positive integer k, find the k’th smallest element in the Binary Search Tree.

July 4, 2015

Given a Binary Search Tree (BST) of integer values and a range [low, high], return count of nodes where all the nodes under that node (or subtree rooted with that node) lie in the given range.

July 2, 2015

Given a Binary Search Tree (BST) and a range, count number of nodes that lie in the given range.

May 28, 2015

Design a data structure to do reservations of future jobs on a single machine under following constraints. 1) Every job requires exactly k time units of the machine. 2) The machine can do only one job at a time.

May 11, 2015

In a Binary Search Tree (BST), all keys in left subtree of a key must be smaller and all keys in right subtree must be greater. So a Binary Search Tree by definition has distinct keys.

April 14, 2015

What is Handshaking Lemma? Handshaking lemma is about undirected graph. In every finite undirected graph number of vertices with odd degree is always even.

April 1, 2015

Hash Table supports following operations in Θ(1) time.

March 20, 2015

Given A binary Tree, how do you remove all the half nodes (which has only one child)? Note leaves should not be touched as they have both children as NULL.

March 19, 2015

Given a Binary Search Tree (BST) and a positive integer k, find the k’th largest element in the Binary Search Tree.

February 28, 2015

A vertex cover of an undirected graph is a subset of its vertices such that for every edge (u, v) of the graph, either ‘u’ or ‘v’ is in vertex cover.

February 14, 2015

A complete binary tree is a binary tree whose all levels except the last level are completely filled and all the leaves in the last level are all to the left side.

February 8, 2015

A full binary tree is defined as a binary tree in which all nodes have either zero or two child nodes. Conversely, there is no node in a full binary tree, which has one child node.

January 31, 2015

Given a Binary Tree, find sum of all left leaves in it. For example, sum of all left leaves in below Binary Tree is 5+23+50 = 78.

January 13, 2015

Given a Binary Tree and a number k, remove all nodes that lie only on root to leaf path(s) of length smaller than k.

December 21, 2014

Given a Binary Tree and a key ‘k’, find distance of the closest leaf from ‘k’.

December 18, 2014

Consider lines of slope -1 passing between nodes (dotted lines in below diagram). Diagonal sum in a binary tree is sum of all node’s data lying between these lines.

December 15, 2014

Given a Binary Tree, we need to print the bottom view from left to right.