## Count of different groups using Graph

Given a graph with N nodes having values either P or M. Also given K pairs of integers as (x, y) representing the edges in… Read More »

Given a graph with N nodes having values either P or M. Also given K pairs of integers as (x, y) representing the edges in… Read More »

Given an ancestor matrix mat[n][n] where the ancestor matrix is defined as below. mat[i][j] = 1 if i is ancestor of j mat[i][j] = 0,… Read More »

Given a 2D array of characters with M rows and N columns. The task is to print all the possible paths from top (first row)… Read More »

Given a connected acyclic graph with N nodes and N-1 edges, find out the pair of nodes that are at even distance from each other.… Read More »

Given N dependencies of the form X Y, where X & Y represents two different tasks. The dependency X Y denotes dependency of the form… Read More »

Depth First Search (DFS) has been discussed in this article which uses adjacency list for the graph representation. In this article, adjacency matrix will be… Read More »

Given a graph of N nodes, E edges, a node X and a distance K. The task is to print all the nodes within the… Read More »

Given a rooted tree (assume root is 1) of N nodes and Q queries, each of the form (Val, Node). For each query, the task… Read More »

Given a tree with N nodes and N-1 edges with root at 1 and given an array of N-1 integers. The task is to assign… Read More »

Given a connected graph with N vertices. The task is to select k(k must be less than or equals to n/2, not necessarily minimum) vertices… Read More »

Given a graph with N nodes and K bidirectional edges between them find the number of nodes which can be reachable from a particular. Two… Read More »

Given start and finish times of DFS traversal of N vertices that are available in a Rooted tree, the task is to construct the tree… Read More »

Given a tree, and the weights (in the form of strings) of all the nodes, the task is to count the nodes whose weighted string… Read More »

Given a tree, and the weights (in the form of strings) of all the nodes, the task is to count the nodes whose weights does… Read More »