Skip to content

Tag Archives: n-ary-tree

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
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
Given an N-ary tree and an array val[] which stores the values associated with all the nodes. Also given are a leaf node X and… Read More
Given an n-ary tree rooted at vertex 1. The tree has n vertices and n-1 edges. Each node has a value associated with it and… Read More
Given an N-ary tree T of N nodes, the task is to calculate the longest path between any two nodes(also known as the diameter of… Read More
Given the value of ‘N’ and ‘I’. Here, represents the number of internal nodes present in an N-ary tree and every node of the N-ary can… Read More
Given a N-ary tree, the task is to print the level with the maximum number of nodes. Examples:   Input : For example, consider the following tree… Read More
Given an N-ary tree, print all the levels with odd and even number of nodes in it.  Examples:  For example consider the following tree 1… Read More
Given an N-ary tree, print all the levels with odd and even number of nodes in it.  Examples:  For example consider the following tree 1… Read More
Given an N-ary tree, print the number of leaf nodes in the subtree of every node. Examples:   Input: 1 / \ 2 3 / | \… Read More
Given an n-ary tree, print preorder traversal of it. Example :   Preorder traversal of below tree is A B K N M J F D… Read More
Given a K-ary Tree. The task is to write an iterative program to perform the preorder traversal of the given n-ary tree. Examples:   Input: 3-Array… 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 an element x, task is to find the value of its immediate smaller element. Example : Input : x = 30 (for above tree)… Read More
Given an N-ary tree, find sum of all elements in it.  Example :   Input : Above tree Output : Sum is 536   Recommended: Please… Read More

Start Your Coding Journey Now!