Octal equivalents of connected components in Binary valued graph
Given a binary valued undirected graph with V vertices and E edges, the task is to find the octal equivalents of all the connected components of the graph. A binary valued graph can be considered as having only binary numbers (0 or 1) as the vertex values....
read more
Minimize count of unequal elements at corresponding indices between given arrays
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 minimize the count of unequal same-indexed elements(Ai != Bi) from the two arrays by swapping between any pair of given indices in array A[]....
read more
Construct a Graph from size of components for each node
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 component of node i. The task is to find the edges for the possible graph else print -1....
read more
Maximum GCD of all nodes in a connected component of an Undirected Graph
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 assigned to each node, the task is to find the maximum GCD among the GCD of all connected components in the graph....
read more
Queries to check if vertices X and Y are in the same Connected Component of an Undirected Graph
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 the vertices X and Y are in the same connected component of the Graph....
read more
Check if the length of all connected components is a Fibonacci number
Given an undirected graph with V vertices and E edges, the task is to find all the connected components of the graph and check if each of their lengths are a Fibonacci number or not. For example, consider the following graph....
read more
Maximum sum of values of nodes among all connected components of an undirected graph
Given an undirected graph with V vertices and E edges. Every node has been assigned a given value. The task is to find the connected chain with the maximum sum of values among all the connected components in the graph. Examples:...
read more
Strongly Connected Component meaning in DSA
Strongly Connected Component (SCC) is a concept in graph theory, specifically in directed graphs. A subgraph of a directed graph is considered to be an SCC if and only if for every pair of vertices A and B, there exists a path from A to B and a path from B to A....
read more
Connected component definition & meaning in DSA
Connected component in an undirected graph refers to a group of vertices that are connected to each other through edges, but not connected to other vertices outside the group....
read more
Number of connected components of a graph ( using Disjoint Set Union )
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 find the total number of connected components in the graph using Disjoint Set Union algorithm....
read more
Check for transitive property in a given Undirected Graph
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 check if all triplets of the undirected graph satisfies the transitive property or not. If found to be true, then print “YES”. Otherwise, print “NO”....
read more
Minimize cost to color all the vertices of an Undirected Graph using given operation
Given two integers V and E representing the number of vertices and edges of an undirected graph G(V, E), a list of edges EdgeList, and an array A[] representing the cost to color each node, the task is to find the minimum cost to color the graph using the following operation:...
read more