Skip to content

Category Archives: Graph

Given an undirected graph with N vertices and M edges and no self loops or multiple edges. The task is to convert the given undirected… Read More
Given an undirected graph g, the task is to print the number of connected components in the graph. Examples:   Input:   Output: 3 There are three connected… Read More
Given a graph, the task is to detect a cycle in the graph using degrees of the nodes in the graph and print all the… Read More
Given a permutation P (P1, P2, P3, … Pn) of first n natural numbers. Find the minimum number of operations to convert it into an… Read More
Uniform-Cost Search is a variant of Dijikstra’s algorithm. Here, instead of inserting all vertices into a priority queue, we insert only source, then one by… Read More
Given an edge list of a graph we have to find the sum of degree of all nodes of a undirected graph. Example   Examples:   Input :… Read More
Given an undirected unweighted connected graph consisting of n vertices and m edges. The task is to find any spanning tree of this graph such… Read More
Given an array arr[] of size N consisting of distinct integers from range [0, N – 1] arranged in a random order. Also given a… Read More
Given a connected undirected weighted graph with N nodes and M edges. The task is to perform given queries and find the weight of the… Read More
Given a directed graph G with N vertices and M edges. The task is to find the length of the longest directed path in Graph.Note:… Read More
Given a weighted undirected connected graph with N nodes and M edges. Some of the nodes are marked as good. The task is to find… Read More
Given a graph with N nodes and M edges. The task is to find the number of ways to select a node from each connected… Read More
Given an n-ary tree rooted at vertex 1. The tree has n vertices and n-1 edges. Each node has a value associated with it and… Read More
Given a binary grid of order r * c and an initial position. The task is to find the minimum distance from the source to… Read More
Given a complete graph with N vertices, the task is to count the number of ways to remove edges such that the resulting graph has… Read More

Start Your Coding Journey Now!