## Shortest distance between two nodes in an infinite binary tree

Consider you have an infinitely long binary tree having a pattern as below: 1 / \ 2 3 / \ / \ 4 5 6… Read More »

Quick Links for Tree

Quizzes |

Consider you have an infinitely long binary tree having a pattern as below: 1 / \ 2 3 / \ / \ 4 5 6… Read More »

Given an array arr[0 . . . n-1]. The task is to perform the following operation: Find the maximum of elements from index l to… Read More »

Given a binary tree, find the maximum vertical level sum in binary tree. Examples: Input : 3 / \ 4 6 / \ / \… Read More »

We have discussed recursive segment tree implementation. In this post, iterative implementation is discussed. Let us consider the following problem understand Segment Trees. We have… Read More »

Round 1: Round 1 was for 200 marks. 25 MCQs and 2 coding questions .The MCQs were mostly on aptitude and some were Technical (C++… Read More »

Given a binary search tree of n nodes with distinct values. Also given are Q queries. Each query consists of a node value that has… Read More »

Given N elements to be inserted into Binary Search Tree. The task is to construct a binary search tree with only insert operation and finally… Read More »

A recursive and a non-recursive program to delete an entire binary tree has already been discussed in the previous posts. In this post, deleting the… Read More »

Given n nodes of a tree and their connections, print Subtree nodes of every node. Subtree of a node is defined as a tree which… Read More »

Given a Binary Search Tree and a number N, the task is to find the smallest number in the binary search tree that is greater… Read More »

Write a function to print spiral order traversal of a tree. For below tree, function should print 1, 2, 3, 4, 5, 6, 7. You… Read More »

Given a binary tree and a node, print all cousins of given node. Note that siblings should not be printed. Examples: Input : root of… Read More »

What is Calkin Wilf Sequence? A Calkin-Wilf tree (or sequence) is a special binary tree which is obtained by starting with the fraction 1/1 and… Read More »

Given a root node to a tree, find the sum of all the leaf nodes which are at maximum depth from root node. Example: 1… Read More »

Given a binary tree, flatten it into linked list in-place. Usage of auxiliary data structure is not allowed. After flattening, left of each node should… Read More »