Given a N x M matrix. Each cell of the matrix has a numerical value pointing to the next cell it leads to. The values… Read More

# Tag Archives: BFS

Given a Generic Tree consisting of N nodes valued from 0 to (N – 1) where P[i]th in the array P[] denotes ith nodes parent(1-based… Read More

Given a Generic Tree consisting of N nodes, the task is to find the ZigZag Level Order Traversal of the given tree. Examples: Input: Output:13… Read More

Given an undirected graph consisting of N nodes and M edges, the task is to find the minimum length of the path from Node 1… Read More

Given two integers N and M, the task is to find the sequence of the minimum number of operations required to convert the number N… Read More

Given a generic tree consisting of N nodes and (N – 1) edges and an array of queries query[] of size Q consisting of the… Read More

Given an undirected and unweighted graph of N nodes and M edges, the task is to count the minimum length paths between node 1 to… Read More

Given a matrix mat[][] containing only of 0s and 1s, and an array queries[], the task is for each query, say k, is to find… Read More

Given a directed and weighted graph of N nodes and M edges, the task is to count the number of shortest length paths between node… Read More

Given a directed and weighted graph of N nodes and M edges, the task is to find the 1st to Kth shortest path lengths from… Read More

Given two numbers N and M, the task is to find the minimum number of moves to change N to M or -1 if it’s… Read More

Given a matrix of dimensions N*M consisting of characters ‘M’, ‘#’, ‘.’ and only a single instance of ‘A’. The task is to print any… 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

Generating Random Unweighted Binary Tree: Since this is a tree, the test data generation plan is such that no cycle gets formed. The number of… Read More

Given an unweighted graph and a boolean array A[ ], where if the ith index of array A[ ] denotes if that node can can… Read More