Skip to content

Tag Archives: DFS

Given an integer N, the task is to find the path from the Nth node to the root of a Binary Tree of the following… Read More
Given a Binary Tree, the task is to remove the leaf nodes of the Binary Tree during each operation and print the count. Examples: Input:  … Read More
Given an N-Ary tree, the task is to print all root to leaf paths of the given N-ary Tree. Examples: Input:         … Read More
Given an N-ary Tree consisting of N nodes valued from 1 to N, an array arr[] consisting of N positive integers, where arr[i] is the… Read More
Given an undirected graph with N vertices and N edges that contain only one cycle, and an array arr[] of size N, where arr[i] denotes… Read More
Given a Binary Tree, the task is to find the sum of all such nodes from the given tree whose sum of left and right… Read More
Given an N-ary tree rooted at 1, the task is to assign values from the range [0, N – 1] to each node in any… Read More
Given a string S of size N and a positive integer K ( where N % K = 0), the task is to find the… Read More
Given a Binary Tree consisting of N nodes and two integers R and K. Each edge of the tree has a positive integer associated with… Read More
Given an N-array tree of N nodes, rooted at 1, with edges in the form {u, v}, and an array values[] consisting of N integers.… Read More
Tarjan’s Algorithm: The Tarjan’s Algorithm is an efficient graph algorithm that is used to find the Strongly Connected Component(SCC) in a directed graph by using… Read More
Given a directed graph G N nodes and E Edges consisting of nodes valued [0, N – 1] and a 2D array Edges[][2] of type… Read More
Given a Binary Tree, the task is to find the sum of all the specially balanced nodes in the given Binary Tree. A specially balanced… Read More
Given a Binary Tree, the task is to print the middle nodes of each level of a binary tree. Considering M to be the number… Read More
Given a weighted undirected graph T consisting of nodes valued [0, N – 1] and an array Edges[][3] of type {u, v, w} that denotes… Read More