## Sum of the minimum elements in all connected components of an undirected graph

Given an array A of N numbers where Ai represent the value of the (i+1)th node. Also given are M pair of edges where u… Read More »

## Find n-th node in Postorder traversal of a Binary Tree

Given a Binary tree and a number N, write a program to find the N-th node in the Postorder traversal of the given Binary tree.… Read More »

## Vertical width of Binary tree | Set 1

Given a binary tree, find the vertical width of the binary tree. The width of a binary tree is the number of vertical paths. In… Read More »

## ZigZag Tree Traversal

Write a function to print ZigZag order traversal of a binary tree. For the below binary tree the zigzag order traversal will be 1 3… Read More »

## Construct Full Binary Tree using its Preorder traversal and Preorder traversal of its mirror tree

Given two arrays that represent Preorder traversals of a full binary tree and its mirror tree, we need to write a program to construct the… Read More »

## Construct BST from its given level order traversal

Construct the BST (Binary Search Tree) from its given level order traversal. Examples: Input : arr[] = {7, 4, 12, 3, 6, 8, 1, 5,… Read More »

## Sum of nodes on the longest path from root to leaf node

Given a binary tree containing n nodes. The problem is to find the sum of all nodes on the longest path from root to leaf… Read More »

## Count pairs from two BSTs whose sum is equal to a given value x

Given two BSTs containing n1 and n2 distinct nodes respectively. Given a value x. The problem is to count all pairs from both the BSTs… Read More »

## Find sum of all right leaves in a given Binary Tree

Given a Binary Tree, find sum of all right leaves in it. Similar article : Find sum of all left leaves in a given Binary… Read More »

## Program to print Sum of even and odd elements in an array

Prerequisite – Array Basics Given an array, write a program to find the sum of values of even and odd index positions separately. Examples: Input… Read More »

## Find median of BST in O(n) time and O(1) space

Given a Binary Search Tree, find median of it. If no. of nodes are even: then median = ((n/2th node + (n+1)/2th node) /2 If… Read More »

## Find sum of all left leaves in a given Binary Tree

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+1=6.… Read More »

## Circular Linked List | Set 2 (Traversal)

We have discussed Circular Linked List Introduction and Applications, in the previous post on Circular Linked List. In this post, traversal operation is discussed. Recommended:… Read More »

## Find next right node of a given key

Given a Binary tree and a key in the binary tree, find the node right to the given key. If there is no node on… Read More »

## Construct a special tree from given preorder traversal

Given an array ‘pre[]’ that represents Preorder traversal of a spacial binary tree where every node has either 0 or 2 children. One more array… Read More »