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

# Category Archives: Graph

Prerequisite: Graph Theory Basics – Set 1, Graph Theory Basics – Set 2 A graph G = (V, E) consists of a set of vertices… Read More

Given an integer n and a set of characters A of size k, find a string S such that every possible string on A of… Read More

Given two arrays of integers arr and P such that after a cycle an element arr[i] will be at location arr[P[i]]. The task is to… Read More

Given a tree, with N nodes and E edges (every edge is denoted by two integers, X, Y stating that X is the parent of… Read More

Given a square matrix mat every element of which is either 0 or 1. A value 1 means connected and 0 means not connected. The… Read More

Given integers ‘N’ and ‘K’ where, N is the number of vertices of an undirected graph and ‘K’ denotes the number of edges in the… Read More

Given a graph and two vertices src and dest, count the total number of paths from src to dest where the length of the path… Read More

Given a tree check if it is linear or not. 1 / \ 2 3 Linear as we can form a lime 2 1 3… Read More

Given a directed graph represented as an adjacency matrix and an integer ‘k’, the task is to find all the vertex pairs that are connected… Read More

In graph theory, edge coloring of a graph is an assignment of “colors” to the edges of the graph so that no two adjacent edges… Read More

Given a Markov chain G, we have the find the probability of reaching the state F at time t = T if we start from… Read More

Pre-Requisites: Depth First Search | Parent Array RepresentationGiven a parent array representation of a binary tree, we need to find the number of Isosceles triangles… Read More

Given n companies and m oil mines having values, the task is to distribute the mines among n companies in a fair manner. That is… Read More