Given a Binary Search Tree (BST) and a range, count number of nodes that lie in the given range.
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.
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.
What is Handshaking Lemma? Handshaking lemma is about undirected graph. In every finite undirected graph number of vertices with odd degree is always even.
Hash Table supports following operations in Θ(1) time.
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.
Given a Binary Search Tree (BST) and a positive integer k, find the k’th largest element in the Binary Search Tree.
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.
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.
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.
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.
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.
Given a Binary Tree and a key ‘k’, find distance of the closest leaf from ‘k’.
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.
Given a Binary Tree, we need to print the bottom view from left to right.
Let us consider the following problem to understand Binary Indexed Tree.
Reverse DNS look up is using an internet IP address to find a domain name. For example, if you type 22.214.171.124 in browser, it automatically redirects to google.in.
Given n appointments, find all conflicting appointments.
Given a Perfect Binary Tree like below: (click on image to get a clear view)
Top view of a binary tree is the set of nodes visible when the tree is viewed from the top. Given a binary tree, print the top view of it. The output nodes can be printed in any order.