##
Create a Doubly Linked List from a Ternary Tree
May 23, 2016

Given a ternary tree, create a doubly linked list out of it. A ternary tree is just like binary tree but instead of having two… Read More »

May 23, 2016

Given a ternary tree, create a doubly linked list out of it. A ternary tree is just like binary tree but instead of having two… Read More »

May 19, 2016

Given a Binary Tree, print it in two dimension. Examples: Input : Pointer to root of below tree 1 / \ 2 3 / \… Read More »

May 18, 2016

Given a Binary Tree having odd and even elements, sink all its odd valued nodes such that no node with odd value could be parent… Read More »

May 12, 2016

Given an n-ary tree, count number of ways to traverse an n-ary (or a Directed Acyclic Graph) tree starting from the root vertex. Suppose we… Read More »

May 9, 2016

Given a Binary Tree, find density of it by doing one traversal of it. Density of Binary Tree = Size / Height Examples: Input: Root… Read More »

May 8, 2016

Given a Binary Tree, convert it into Doubly Linked List where the nodes are represented Spirally. The left pointer of the binary tree node should… Read More »

May 7, 2016

We have discussed recursive implementation to delete an entire binary tree here. We strongly recommend you to minimize your browser and try this yourself first. Now… Read More »

May 4, 2016

Given a binary tree, print all its root to leaf paths without using recursion. For example, consider the following Binary Tree. 6 / \ 3… Read More »

May 3, 2016

Consider lines of slope -1 passing between nodes. Given a Binary Tree, print all diagonal elements in a binary tree belonging to same line. Input… Read More »

Given a Binary Tree (BT), convert it to a Doubly Linked List(DLL) In-Place. The left and right pointers in nodes are to be used as… Read More »

May 1, 2016

Given a BST (Binary Search Tree) that may be unbalanced, convert it into a balanced BST that has minimum possible height. Examples : Input: 30… Read More »

April 24, 2016

Perfect Binary Tree using Specific Level Order Traversal in Set 1. The earlier traversal was from Top to Bottom. In this post, Bottom to Top… Read More »

April 17, 2016

Given an ancestor matrix mat[n][n] where Ancestor matrix is defined as below. mat[i][j] = 1 if i is ancestor of j mat[i][j] = 0, otherwise… Read More »

April 15, 2016

Given a Binary Tree where all values are from 0 to n-1. Construct an ancestor matrix mat[n][n]. Ancestor matrix is defined as below. mat[i][j] =… Read More »

April 13, 2016

Given a Binary Tree, find vertical sum of the nodes that are in same vertical line. Print all sums through different vertical lines.