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

# Tag Archives: connected-components

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 an array arr[] consisting of N strings representing the name of the students in the class and another array of pairs P[][2] such that… Read More

Given an array arr[] consisting of values of N vertices of an initially unconnected Graph and an integer M, the task is to connect some… Read More

Given an undirected graph consisting of V vertices and a 2d array E[][2] denoting edges between pairs of nodes. Given another array arr[] representing values… Read More

Given an undirected graph G with vertices numbered in the range [1, N] and an array Edges[][] consisting of M edges, the task is to… Read More

Given an integer N, denoting the number of computers connected by cables forming a network and a 2D array connections[][], with each row (i, j)… Read More

Given an undirected graph G with vertices numbered in the range [0, N] and an array Edges[][] consisting of M edges, the task is to… Read More

Given an n-ary tree T, the task is to find a node whose removal minimizes the maximum size of all forests(connected components) generated. Examples: Input: … Read More

Given an undirected graph G with N nodes, M edges, and an integer K, the task is to find the maximum count of edges that… Read More

Given a Tree consisting of N nodes valued in the range [0, N) and an array Queries[] of Q integers consisting of values in the… Read More

Given an undirected graph consisting of N nodes containing values from the range [1, N] and M edges in a matrix Edges[][], the task is… Read More

Given two arrays A[] and B[] consisting of N positive integers and a matrix List[][] consisting of M pairs of indices, the task is to… Read More

Given a Tree having N nodes connected by N − 1 edge and a single disconnected node, the task is to find the diameters for… Read More

Given an undirected graph consisting of N vertices and M edges and queries Q[][] of the type {X, Y}, the task is to check if… Read More