## Levelwise Alternating GCD and LCM of nodes in Segment Tree

A Levelwise GCD/LCM alternating segment tree is a segment tree, such that at every level the operations GCD and LCM alternate. In other words at… Read More »

Quick Links for Tree

Quizzes |

A Levelwise GCD/LCM alternating segment tree is a segment tree, such that at every level the operations GCD and LCM alternate. In other words at… Read More »

Given a binary tree where each node can have at most two child nodes, the task is to find the Euler tour of the binary… Read More »

aaThe diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. In this post,… Read More »

Given a binary tree. Find if a given vertical level of the binary tree is sorted or not. (For the case when two nodes are… Read More »

Consider a tree with n nodes and root. You can jump from one node to any other node on the same height a maximum of… Read More »

Given a Binary Search Tree(BST), convert it to a Binary Tree such that every key of the original BST is changed to key plus sum… Read More »

Given a node x, find the number of children of x(if it exists) in the given n-ary tree. Example : Input : x = 50… Read More »

Given a tree, and the cost of a subtree is defined as |S|*AND(S) where |S| is the size of the subtree and AND(S) is bitwise… Read More »

Given a tree and weights of nodes. Weights are non-negative integers. Task is to find maximum size of a subtree of a given tree such… Read More »

Given an N-ary tree, find the number of siblings of given node x. Assume that x exists in the given n-ary tree. Example : Input… Read More »

Given N numbers and Q queries, each query consists of L and R. Task is to write a program which prints the count of numbers… Read More »

Given a binary tree, task is to find subtree with maximum sum in tree. Examples : Input : 1 / \ 2 3 / \… Read More »

Given a rectangular matrix M[0…n-1][0…m-1], and queries are asked to find the sum / minimum / maximum on some sub-rectangles M[a…b][e…f], as well as queries… Read More »

An ordered tree is an oriented tree in which the children of a node are somehow ordered. It is a rooted tree in which an… Read More »

Euler tour tree (ETT) is a method for representing a rooted tree as a number sequence. When traversing the tree using Depth for search(DFS), insert… Read More »