# Tag Archives: DFS

Given a 2-D array matrix[][] of size M*N and an integer K. For each occurrence of K in the matrix[][], replace K and all the… Read More
Given an adjacency matrix graph[][] of a weighted graph consisting of N nodes and positive weights, the task for each connected component of the graph… Read More
Given a N x M matrix. Each cell of the matrix has a numerical value pointing to the next cell it leads to. The values… Read More
Given a positive integer K and a weighted undirected connected graph of N nodes and E edges as an array Edges[] of the type {u,… Read More
Given an undirected, connected tree with N nodes valued from 0 to N – 1 and an array edges[] represents the edges between two nodes,… 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
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
My Personal Notes arrow_drop_up Save
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