Skip to content

Category Archives: Graph

Given a boolean 2D array, arr[][] of size N*M where a group of connected 1s forms an island. Two cells are said to be connected… Read More
Given an undirected graph consisting of N valued over the range [1, N] such that vertices (i, i + 1) are connected and an array… Read More
Given a directed tree consisting of N nodes valued from [0, N – 1] and M edges, the task is to find the minimum number… Read More
Given an undirected graph consisting of N nodes and M edges, the task is to find the minimum length of the path from Node 1… Read More
Given two integers N and M, the task is to find the sequence of the minimum number of operations required to convert the number N… Read More
Given a generic tree consisting of N nodes and (N – 1) edges and an array of queries query[] of size Q consisting of the… Read More
Given a Graph having N+1 nodes with 2*N-1 edges and a boolean array arr[ ], the task is to find if one can visit every… Read More
Given an undirected and unweighted graph of N nodes and M edges, the task is to count the minimum length paths between node 1 to… Read More
Given an array A[] of size N, for each index i in the range [0, N) the value A[i] denotes the size of the connected… Read More
Given a matrix mat[][] containing only of 0s and 1s, and an array queries[], the task is for each query, say k, is to find… Read More
Given a weighted undirected graph consisting of N nodes and M edges, the task is to find the shortest distance between two nodes A and… Read More
Dijkstra’s Algorithm: It is a graph searching algorithm that uses a Greedy Approach to find the shortest path from the source node to all other… Read More
Mother vertex: A mother vertex in a Graph G = (V, E) is a vertex v such that all other vertices in  G can be… Read More
Given an unweighted bidirectional graph containing N nodes and M edges represented by an array arr[][2]. The task is to find the difference in length… Read More
Given a directed and weighted graph of N nodes and M edges, the task is to count the number of shortest length paths between node… Read More