## Kruskal’s Algorithm (Simple Implementation for Adjacency Matrix)

Below are the steps for finding MST using Kruskal’s algorithm 1. Sort all the edges in non-decreasing order of their weight. 2. Pick the smallest… Read More »

Below are the steps for finding MST using Kruskal’s algorithm 1. Sort all the edges in non-decreasing order of their weight. 2. Pick the smallest… Read More »

We have discussed Prim’s algorithm and its implementation for adjacency matrix representation of graphs. As discussed in the previous post, in Prim’s algorithm, two sets… Read More »

Given an undirected weighted graph. The task is to find the minimum cost of the path from source node to the destination node via an… Read More »

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 »

In graph theory, a dominating set for a graph G = (V, E) is a subset D of V such that every vertex not in… Read More »

Given a graph, the task is to print the DFS traversal of a graph which includes the every step including the backtracking. 1st step:- 0… Read More »

Given an array of words, find any alphabetical order in the English alphabet such that the given words can be considered sorted (increasing), if there… Read More »

Graphs can be used for seemingly unconnected problems. Say the problem of cards which have numbers on both side and you try to create a… Read More »

A graph is a non-linear data structure, which consists of vertices(or nodes) connected by edges(or arcs) where edges may be directed or undirected. In Computer… Read More »

Online Round: This round was held on Hackerrank for 1:30 hrs. There were two questions in this round. A tree was given with upto 10^5 nodes.… Read More »

Given a connected graph, check if the graph is bipartite or not. A bipartite graph is possible if the graph coloring is possible using two… Read More »

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. My… Read More »

Given n nodes of a tree and their connections, print Subtree nodes of every node. Subtree of a node is defined as a tree which… Read More »

Given a directed graph having n nodes. For each node, delete all the outgoing edges except the outgoing edge with minimum weight. Apply this deletion… Read More »

Given an array A of N numbers where Ai represent the value of the (i+1)th node. Also given are M pair of edges where u… Read More »