## Check if the given graph represents a Ring Topology

Given a graph G, the task is to check if it represents a Ring Topology. A Ring Topology is the one shown in the image… Read More »

## Detect Cycle in a Directed Graph using BFS

Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least… Read More »

## Find whether it is possible to finish all tasks or not from given dependencies

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites, for example to pick… Read More »

## Degree of a Cycle Graph

Given the number of vertices in a Cycle Graph. The task is to find the Degree and the number of Edges of the cycle graph.… Read More »

## Total number of Spanning trees in a Cycle Graph

Given the number of vertices in a Cycle graph. The task is to find the Total number of Spanning trees possible. Note: A cycle/circular graph… Read More »

## Coloring a Cycle Graph

Cycle:- cycle is a path of edges and vertices wherein a vertex is reachable from itself. or in other words, it is a Closed walk.… Read More »

## Product of lengths of all cycles in an undirected graph

Given an undirected and unweighted graph. The task is to find the product of the lengths of all cycles formed in it. Example 1: The… Read More »

## Longest chain of arr[i], arr[arr[i]], .. without repetition

Given an array of size n such that elements in array are distinct and in range from 0 to n-1. We need to find out… Read More »

## Print all the cycles in an undirected graph

Given an undirected graph, print all the vertices that form cycles in it. Pre-requisite: Detect Cycle in a directed graph using colors In the above… Read More »

## Detect cycle in an undirected graph using BFS

Given an undirected graph, how to check if there is a cycle in the graph? For example, the following graph has a cycle 1-0-2-1. Recommended:… Read More »

## How does Floyd’s slow and fast pointers approach work?

We have discussed Floyd’s fast and slow pointer algorithms in Detect loop in a linked list. The algorithm is to start two pointers, slow and… Read More »

## Number of single cycle components in an undirected graph

Given a set of ‘n’ vertices and ‘m’ edges of an undirected simple graph (no parallel edges and no self-loop), find the number of single-cycle-components… Read More »

## Find duplicates in constant array with elements 0 to N-1 in O(1) space

Given a constant array of n elements which contains elements from 0 to n-1, with any of these numbers appearing any number of times. Find… Read More »

## Number of loops of size k starting from a specific node

Given two positive integer n, k. Consider an undirected complete connected graph of n nodes in a complete connected graph. The task is to calculate… Read More »

## Magical Indices in an array

Given an array A of integers. Index i of A is said to be connected to index j if j = (i + A[i]) %… Read More »