Breadth First Search

Shortest path in an unweighted graph

Problem Statement Given the directed, connected and unweighted graph G, a Source and a Destination and the task to find the shortest path possible between two given vertices in the graph. Note: The path does not contain any cycle which means path have finite number of vertices. Example Input Expected Output Path : 0 3 Implementation in Shortest path in an unweighted graph

Water Jug problem using BFS

Problem Statement Given two jugs with J1 and J2 litres of capacities which are initially empty. Using these jugs you have to measure L litres of water (L < J2).The (x, y) is the state where x and y are the amount of water in J1 and J2 respectively. The task is to find the path from Water Jug problem using BFS

Breadth First Traversal for a Graph

Breadth First Search (BFS) is a graph traversal algorithm that is used to traverse all the vertices of a graph in a breadthward motion. In other words, it starts the graph traversal from root node and explores all the neighboring nodes first instead of going deep. Example of Breadth First Traversal for a Graph Breadth First Breadth First Traversal for a Graph

Rotten Oranges

Given a 2 dimensional array where each cell is either empty or contains a fresh orange or a rotten orange. Output the time taken to rot all the oranges.

[gravityforms id="5" description="false" titla="false" ajax="true"]