Given 1 to N vertices of a non-cyclic undirected graph with (N-1) edges. The task is to assign values to these edges so that the… Read More

# Category Archives: Graph

Floyd’s cycle finding algorithm or Hair-Tortoise algorithm is a pointer algorithm that uses only two pointers, moving through the sequence at different speeds. This algorithm… Read More

Given a string Str of N characters and two strings S1 and S2 of equal length where S1[i] and S2[i] are related to each other,… Read More

Minimum cost of path between given nodes containing at most K nodes in a directed and weighted graph

Given a directed weighted graph represented by a 2-D array graph[][] of size n and 3 integers src, dst, and k representing the source point,… Read More

Given a directed acyclic graph of N nodes, the task is to find the smallest set of vertices from which the complete graph can be… Read More

Given a connected undirected weighted graph in the form of a 2D array where each row is of the type [start node, end node, weight]… Read More

Given a undirected graph with V vertices and E edges. The task is to perform DFS traversal of the graph. Examples: Input: V = 7,… Read More

Given an array arr[] of size N and an integer K, the task is to find the longest subsequence such that the difference between adjacents… Read More

Given two integers N and M denoting the number of vertices and edges in the graph and array edges[][] of size M, denoting an edge… Read More

Given a graph root, the task is to find the length of the longest increasing sequence in the graph. Example: Input: root = 7—-17 … Read More

Given a graph root, and a value K, the task is to find the number of nodes in the graph whose sum of neighbors is… Read More

Given two integers N and M, the task is to calculate the minimum number of moves to change N to M, where In one move… Read More

Given a graph consisting of N nodes and an array edges[][] denoting an edge from edges[i][0] with edges[i][1]. Given a node K, the task is… Read More

Graph colouring is the task of assigning colours to the vertices of a graph so that: pairs of adjacent vertices are assigned different colours, and… Read More

Pre-requisites: Handshaking theorem. Pendant Vertices Let G be a graph, A vertex v of G is called a pendant vertex if and only if v… Read More