##
BFS for Disconnected Graph
May 17, 2017

In previous post, BFS only with a particular vertex is performed i.e. it is assumed that all vertices are reachable from the starting vertex. But… Read More »

May 17, 2017

In previous post, BFS only with a particular vertex is performed i.e. it is assumed that all vertices are reachable from the starting vertex. But… Read More »

May 3, 2017

Prerequisites : BFS, DFS In BFS and DFS, when we are at a node, we can consider any of the adjacent as next node. So… Read More »

April 23, 2017

Given a graph where every edge has weight as either 0 or 1. A source vertex is also given in the graph. Find the shortest… Read More »

April 15, 2017

How would you design the data structures for a very large social network like Facebook or Linkedln? Describe how you would design an algorithm to… Read More »

March 5, 2017

Given an undirected tree, we need to find the longest path of this tree where a path is defined as a sequence of nodes. Example:… Read More »

March 1, 2017

Given a positive number N, we need to reach to 1 in minimum number of steps where a step is defined as converting N to… Read More »

February 27, 2017

Given a N X N matrix (M) filled with 1 , 0 , 2 , 3 . Find the minimum numbers of moves needed to… Read More »

February 25, 2017

Problem Statement : Given a graph which represents a flow network where every edge has a capacity. Also given two vertices source ‘s’ and sink… Read More »

February 24, 2017

Given N X N matrix filled with 1 , 0 , 2 , 3 . Find whether there is a path possible from source to… Read More »

February 23, 2017

Given a limit N, we need to find out the count of binary digit numbers which are smaller than N. Binary digit numbers are those… Read More »

February 22, 2017

Given a binary matrix of N x M, containing at least a value 1. The task is to find the distance of nearest 1 in… Read More »

February 19, 2017

Given a square chessboard of N x N size, the position of Knight and position of a target is given. We need to find out… Read More »

November 23, 2016

Given a initial number x and two operations which are given below: Multiply number by 2. Subtract 1 from the number. The task is to… Read More »

November 13, 2016

Given a binary matrix of order m*n, the task is to find the distance of nearest 1 for each 0 in the matrix and print… Read More »

November 6, 2016

Given an array containing one digit numbers only, assuming we are standing at first index, we need to reach to end of array using minimum… Read More »