Skip to content

Category Archives: Graph

Given a complete directed graph having N vertices, whose edges weighs ‘1’ or ‘0’, the task is to find a path of length exactly K… Read More
Given an adjacency matrix graph[][] of a weighted graph consisting of N nodes and positive weights, the task for each connected component of the graph… Read More
Weakly Connected Graph: A directed graph ‘G = (V, E)’ is weakly connected if the underlying undirected graph Ĝ is connected.  The underlying undirected graph… Read More
Given a positive integer K and a weighted undirected connected graph of N nodes and E edges as an array Edges[] of the type {u,… Read More
Given a binary matrix mat[][] of dimensions M*N, the task is to check whether there exist T continuous blocks of 0s or not and at… Read More
Given an undirected, connected tree with N nodes valued from 0 to N – 1 and an array edges[][2] represents the edges between two nodes,… Read More
Given a directed graph of N vertices valued from 0 to N – 1 and array graph[] of size K represents the Adjacency List of… Read More
Given a group of N people, each having a unique ID value from 0 to (N – 1) and an array arr[] of M elements… Read More
Given an array arr[] of N strings consisting of lowercase alphabets, the task is to find the number of distinct groups of strings formed after… Read More
Given an undirected unweighted graph of N vertices in the form of adjacency matrix adj[][], the task is to find the number of simple cycles… Read More
Given a disconnected graph G with N vertices and M edges and an array cost[] corresponding to each vertex, the task is to find the… Read More
Here is the collection of the Top 50 list of frequently asked interviews question on Graph. Problems in this Article are divided into three Levels… Read More
Given a positive integer N representing the set of integers [1, N] and an array queries[] of length Q of type {L, K}, the task… Read More
Given an array of pairs arr[][] of length N, and an array queries[] of length M, and an integer R, where queries[i] contain an integer… Read More
Johnson’s algorithm finds the shortest paths between all pairs of vertices in a weighted directed graph. It allows some of the edge weights to be… Read More