Prerequisites – Graph, Spanning tree, Disjoint Set (Union – Find). A minimum spanning tree (MST) T, for a given graph G, spans over all vertices… Read More

# Category Archives: Tree

Given a complete binary tree with values indexed from 1 to N and a key K. The task is to check whether a key exists… Read More

Given an array pre[], representing the Preorder traversal of a Perfect Binary Tree consisting of N nodes, the task is to construct a Perfect Binary… Read More

A Set is a collection of distinct elements. Elements cannot be modified once added. There are various operations associated with sets such as union, intersection,… Read More

Given N pairs, the task is to find the Kth smallest pair and the number of pairs less than the given pair (x, y). Examples:… Read More

Given a Binary Tree, the task is to print the Bottom-left to Upward-right Traversal of the given Binary Tree i.e., the level order traversal having… Read More

AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for… Read More

Given an N-ary Tree consisting of N nodes valued from [0, N – 1] and two binary arrays initial[] and final[] of size N such… Read More

Given a binary tree, the task is to compress all the nodes on the same vertical line into a single node such that if the… Read More

Given an N-array Tree (Generic Tree) and an integer K, the task is to find the Kth smallest element in an N-array Tree. Examples: Input:… Read More

AVL Trees are self-balancing Binary Search Trees where the difference between heights of left and right subtrees cannot be more than one for all nodes.… Read More

Given an array arr[] consisting of N strings and Q queries in form of two strings prefix and suffix, the task for each query is… Read More

Given a Generic Tree consisting of N nodes, the task is to find the average width for each node present in the given tree. The… Read More

Given an integer N, the task is to print all possible Full Binary Trees with N nodes. The value at the nodes does not contribute… Read More

Given two arrays, A[] and B[] consisting of M pairs, representing the edges of the two binary trees of N distinct nodes according to the… Read More