## Find K vertices in the graph which are connected to at least one of remaining vertices

Given a connected graph with N vertices. The task is to select k(k must be less than or equals to n/2, not necessarily minimum) vertices… Read More »

## Coin Change | BFS Approach

Given an integer X and an array arr[] of length N consisting of positive integers, the task is to pick minimum number of integers from… Read More »

## Difference Between BFS and DFS

Breadth First Search BFS stands for Breadth First Search is a vertex based technique for finding a shortest path in graph. It uses a Queue… Read More »

## Minimum number of pairs required to make two strings same

Given two strings s1 and s2 of same length, the task is to count the minimum number of pairs of characters (c1, c2) such that… Read More »

## Minimum steps required to reach the end of a matrix | Set 2

Given a 2d-matrix mat[][] consisting of positive integers, the task is to find the minimum number of steps required to reach the end of the… Read More »

## Minimize the number of steps required to reach the end of the array | Set 2

Given an integer array arr[] of length N consisting of positive integers, the task is to minimize the number of steps required to reach the… Read More »

## Islands in a graph using BFS

Given a boolean 2D matrix, find the number of islands. A group of connected 1s forms an island. For example, the below matrix contains 5… Read More »

## Iterative approach to check for children sum property in a Binary Tree

Given a binary tree, write a function that returns true if the tree satisfies below property: For every node, data value must be equal to… Read More »

## Minimum distance to the corner of a grid from source

Given a binary grid of order r * c and an initial position. The task is to find the minimum distance from the source to… Read More »

## Print the lexicographically smallest BFS of the graph starting from 1

Given a connected graph with N vertices and M edges. The task is to print the lexicographically smallest BFS traversal of the graph starting from… Read More »

## Finding the path from one vertex to rest using BFS

Given an adjacency list representation of a directed graph, the task is to find the path from source to every other node in the graph… Read More »

## Minimum steps to reach any of the boundary edges of a matrix | Set-2

Given an N X M matrix, where ai, j = 1 denotes the cell is not empty, ai, j = 0 denotes the cell is… Read More »

## Print all the levels with odd and even number of nodes in it | Set-2

Given an N-ary tree, print all the levels with odd and even number of nodes in it. Examples: For example consider the following tree 1… Read More »

## Detect Cycle in a Directed Graph using BFS

Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least… Read More »

## Find whether it is possible to finish all tasks or not from given dependencies

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites, for example to pick… Read More »