## Count ways to change direction of edges such that graph becomes acyclic

Given a directed and unweighted graph consisting of N vertices and an array arr[] where ith vertex have a directed edge to arr[i]. The task… Read More »

Given a directed and unweighted graph consisting of N vertices and an array arr[] where ith vertex have a directed edge to arr[i]. The task… Read More »

Given an acyclic undirected graph having N nodes and N-1 edges in the form of a 2D array arr[][] in which every row consists of… Read More »

Given adjacency list representation of a directed graph, the task is to check whether the cost of going from any vertex to any other vertex… 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 »