# Category Archives: Graph

## Right sibling of each node in a tree given as array of edges

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 »

## Find maximum path length in a binary matrix

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 »

## Maximum number of edges among all connected components of an undirected graph

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 »

## Number of Walks from source to destination

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 »

## Check if a given tree graph is linear or not

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 »

## All vertex pairs connected with exactly k edges in a graph

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 »

## Edge Coloring of a Graph

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 »

## Finding the probability of a state at a given time in a Markov chain | Set 2

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 »

## Find the probability of a state at a given time in a Markov chain | Set 1

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 »

## Number of Isosceles triangles in a binary tree

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

## Minimum difference between the highest and the smallest value of mines distributed

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 »

## Jump Pointer Algorithm

The Jump pointer algorithm is a design technique for parallel algorithms that operate on pointer structures, such as arrays or linked list. This algorithm is… Read More »

## Find if an undirected graph contains an independent set of a given size

Given an undirected graph, check if it contains an independent set of size k. Print ‘Yes’ if there exists an independent set of size k.… Read More »

## Maximize number of nodes which are not part of any edge in a Graph

Given a graph with n nodes and m edges. Find the maximum possible number of nodes which are not part of any edge (m will… Read More »

## Basic Properties of a Graph

A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are… Read More »