Category Archives: Graph

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
Given a graph consisting of N nodes, where each node represents an exam and a 2D array Edges[][2] such that each pair of the examâ€¦ Read More
An Adjacency List is used for representing graphs. Here, for every vertex in the graph, we have a list of all the other vertices whichâ€¦ Read More
Problem Description: A city is represented as a two-dimensional rectangular matrix. The outer wall of the given matrix denotes the boundaries of the city. Citizensâ€¦ Read More
Prerequisites – Graph, Spanning tree, Disjoint Set (Union – Find). A minimum spanning tree (MST) T, for a given graph G, spans over all verticesâ€¦ Read More
Given an array arr[] consisting of N integers, the task is to find the minimum cost to sort the given array arr[] in ascending orderâ€¦ Read More