# Tag Archives: Graph Traversals

Given a tree with N nodes and (N-1) edges and source node is at 1st position. There are Q queries, each of the type {pos,… Read More
Given a graph G(V, E), divide it into two sets such that no two vertices in a set are connected directly. If not possible print… 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 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[] 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[] 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[] 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