Skip to content

Tag Archives: DFS

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 Binary Tree consisting of N nodes having no values in it and an integer X, that represents the value of the root node,… Read More
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and… Read More
Given a Generic Tree consisting of N nodes numbered from 0 to N – 1 which is rooted at node 0 and an array val[]… Read More
Given a generic tree consisting of N nodes, the task is to find the maximum sum of the path from the root to the leaf… Read More
Given a Binary Search Tree, a target node in the BST, and an integer value K, the task is to find the sum of all… Read More
Given a Binary tree, and target sum as K, the task is to print all the possible paths from root to leaf that has the… Read More
Given an N-ary Tree consisting of N nodes valued from [0, N – 1] and two binary arrays initial[] and final[] of size N such… Read More
Given a Generic Tree consisting of N nodes, the task is to find the average width for each node present in the given tree. The… Read More
Given a positive integer N denoting the number of astronauts(labelled from 0 from (N – 1))and a matrix mat[][] containing the pairs of astronauts that… Read More
Given a graph, G consisting of N nodes, a source S, and an array Edges[][2] of type {u, v} that denotes that there is an… Read More
Given a directed graph G consisting of N nodes and N-1 edges, and a positive integer K, and initially, all the nodes of the graph… Read More
Given a tree consisting of N nodes and rooted at node 1, also given an array Q[] of M pairs, where each array element represents… Read More
Given a binary matrix mat[][] of dimensions N*M, the task is to find the minimum number of flips required from the given binary matrix such… Read More