Skip to content

Category Archives: Tree

You are given a set of links, e.g. a ---> b b ---> c b ---> d a ---> e Print the tree that would… Read More
There are two conventions to define the height of a Binary Tree  Number of nodes on the longest path from the root to the deepest… Read More
Write a function to detect if two trees are isomorphic. Two trees are called isomorphic if one of them can be obtained from other by… Read More
Given a Binary Tree (Bt), convert it to a Doubly Linked List(DLL). The left and right pointers in nodes are to be used as previous… Read More
A binary tree is a tree data structure in which each node can have at most two children, which are referred to as the left… Read More
Given Linked List Representation of Complete Binary Tree, construct the Binary tree. A complete binary tree can be represented in an array in the following… Read More
We have discussed the level-order traversal of a tree in the previous post. The idea is to print the last level first, then the second… Read More
We have discussed a simple iterative postorder traversal using two stacks in the previous post. In this post, an approach with only one stack is… Read More
We have discussed iterative inorder and iterative preorder traversals. In this post, iterative postorder traversal is discussed, which is more complex than the other two… Read More
Given a Binary Tree, find size of the Largest Independent Set(LIS) in it. A subset of all tree nodes is an independent set if there… Read More
We have introduced segment tree with a simple example in the previous post. In this post, Range Minimum Query problem is discussed as another example… Read More
Let us consider the following problem to understand Segment Trees.We have an array arr[0 . . . n-1]. We should be able to  Find the… Read More
A complete binary tree is a binary tree where each level ‘l’ except the last has 2^l nodes and the nodes at the last level… Read More
Using Morris Traversal, we can traverse the tree without using stack and recursion. The algorithm for Preorder is almost similar to Morris traversal for Inorder.… Read More
Team : Transportation Location :Hyderabad Round 1 (Online Test) Q1. Find the kth largest value in a BST Q2. Swap the alternate nodes in a singly linked… Read More