Given a binary tree, find the total time to visit all nodes from the root node. Visiting a child node from its parent node will… Read More

# Tag Archives: DFS

Given a undirected graph with V vertices and E edges. The task is to perform DFS traversal of the graph. Examples: Input: V = 7,… Read More

Given a binary tree and a number K, the task is to count the number of nodes having the average of the values in their… Read More

Question: Given an arbitrary binary tree, convert it to a binary tree that holds Children Sum Property. You can only increment data values in any… Read More

Given two integers N and M denoting the number of vertices and edges in the graph and array edges[][] of size M, denoting an edge… Read More

Given a graph root, the task is to find the length of the longest increasing sequence in the graph. Example: Input: root = 7—-17 … Read More

Given a graph root, and a value K, the task is to find the number of nodes in the graph whose sum of neighbors is… Read More

We have discussed flattening of a multi-level linked list where nodes have two pointers down and next. In the previous post, we flattened the linked… Read More

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