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

# Category Archives: Graph

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

Given a 2D array, arr of size N*N where arr[i][j] denotes the cost to complete the jth job by the ith worker. Any worker can… Read More

Given an array arr[] of N pairs of strings representing a directed graph, where each pair of the strings represents an edge between the nodes… Read More