Skip to content

Tag Archives: Graph Traversals

Given a positive integer K and a weighted undirected connected graph of N nodes and E edges as an array Edges[] of the type {u,… Read More
Given the root node of an N-ary tree and an integer K, the task is to convert the given tree into adjacency list representation and… Read More
Given a directed graph of N vertices valued from 0 to N – 1 and array graph[] of size K represents the Adjacency List of… Read More
Given a Graph having N+1 nodes with 2*N-1 edges and a boolean array arr[ ], the task is to find if one can visit every… Read More
Given a graph consisting of N nodes, where each node represents an exam and a 2D array Edges[][2] such that each pair of the exam… Read More
Given a positive integer N denoting the number of astronauts(labelled from 0 from (N – 1))and a matrix mat[][] containing the pairs of astronauts that… Read More
Given a graph, G consisting of N nodes, a source S, and an array Edges[][2] of type {u, v} that denotes that there is an… Read More
Given an undirected Graph consisting of N nodes in the form of an adjacency matrix graph[][] of size N*N, the task is to print all… Read More
Given a positive integer N, the task is to find the number of unique permutations of first N natural numbers having sum of the adjacent… Read More
Given an array arr[] consisting of N strings representing the name of the students in the class and another array of pairs P[][2] such that… Read More
Given a matrix mat][][] of size M x N which represents the topographic map of a region, and 0 denotes land and 1 denotes elevation,… Read More
Given an undirected graph consisting of N vertices and M edges and an array edges[][], with each row representing two vertices connected by an edge,… Read More
Given an undirected weighted graph G consisting of N vertices and M edges, and two arrays Edges[][2] and Weight[] consisting of M edges of the… Read More
Given two graphs G1 and G2, the task is to find the union and intersection of the two given graphs, i.e. (G1 ∪ G2) and… Read More
Given a matrix arr[][], consisting of only 0, 1, and 2, that represents an empty ward, an uninfected patient, and an infected patient respectively. In… Read More

Start Your Coding Journey Now!