Given a tree, and the weights of all the nodes and an integer x, the task is to find a node i such that |weight[i]… Read More

# Tag Archives: Trees

Given a tree with N nodes, and two integers K and V. The task is to find the Kth node in the DFS traversal of… Read More

Graph : A graph is collection of two sets V and E where V is a finite non-empty set of vertices and E is a… Read More

Tree:- A connected graph without any circuit is called a Tree. In other words, a tree is an undirected graph G that satisfies any of… Read More

Given a rooted tree and not necessarily binary. The tree contains N nodes, labeled 1 to N. You are given the tree in the form… Read More

The entire process consisted of 5 rounds: 1 online coding, 1 debugging, 2 Technical and 1 HR/System Design Round. The minimum criteria for the online… Read More

Given a tree of N nodes and N-1 edges. The task is to print the DFS of the subtree of a given node for multiple… Read More

Given two binary trees. The task is to write a program to check if the two trees are identical in structure. In the above figure… Read More

Given a binary tree, flatten it into a linked list. After flattening, the left of each node should point to NULL and right should contain… Read More

Given a binary tree. The task is to check if the binary tree is sorted level-wise or not. A binary tree is level sorted if… Read More

Given a binary tree, change the value in each node to sum of all the values in the nodes in the right subtree including its… 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

Given a string, find the longest substring which is palindrome. For example, if the given string is “forgeeksskeegfor”, the output should be “geeksskeeg”. Prerequisite :… Read More

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

There are two variants of ceilingEntry() in Java.util.TreeMap, both are discussed in this article. 1. ceilingEntry(K Key) : It is used to return a key-value… Read More