# Tag Archives: n-ary-tree

Given the root of an n-ary tree, the task is to find the number of subtrees that have duplicates in the n-ary tree. Two trees… Read More
Given an array arr[] of size M that contains the post-order traversal of a complete N-ary tree, the task is to generate the N-ary tree… Read More
Given an undirected tree with N nodes numbered from 1 to N and an array A[] where A[i] denotes the value assigned to (i+1)th node.… Read More
Find the number of leaf nodes in a perfect N-ary tree of height K. Note: As the answer can be very large, return the answer… Read More
Given an N-ary Tree. The task is to print the level order traversal of the tree where each level will be in a new line.… Read More
Given an n-ary Tree having N nodes numbered from 1 to N, the task is to print a list of nodes containing 0, 1, 2,… Read More
Given an N-ary tree consisting of N nodes with values from 1 to N rooted at 1, for all nodes, print the number of ancestors… Read More
Given an N-ary tree. The task is to replace the values of each node with the sum of all its subtrees and the node itself. … Read More
Given an N-ary tree root, the task is to find the count of nodes such that their subtree is a binary tree. Example: Input: Tree… Read More
Given a generic tree such that each node has a value associated with it, the task is to find the largest number of connected nodes… Read More
Given an N-ary tree root, the task is to find the number of non-leaf nodes in the tree such that all the leaf nodes in… Read More
Given an N-ary tree root, the task is to check if it is symmetric horizontally (Mirror image of itself). Example: Input:   root =     … Read More
Given an N-ary tree root and a list of K nodes, the task is to find the number of common ancestors of the given K… Read More
Given a Generic Tree consisting of N nodes valued from 0 to (N – 1) where P[i]th in the array P[] denotes ith nodes parent(1-based… Read More
Given a tree consisting of N nodes an array edges[] of size N – 1 such that for each {X, Y, W} in edges[] there… Read More