Skip to content

Tag Archives: n-ary-tree

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[][3] of size N – 1 such that for each {X, Y, W} in edges[] there… Read More
Given a Generic Tree consisting of N nodes, the task is to find the ZigZag Level Order Traversal of the given tree. Examples: Input: Output:13… Read More
Given a N ary Tree consisting of N nodes, the task is to find the minimum distance from node A to node B of the… Read More
Given a generic tree consisting of N nodes and (N – 1) edges and an array of queries query[] of size Q consisting of the… Read More

Start Your Coding Journey Now!