## Maze pathfinding implementation (BFS) not giving correct path

I am trying to get the shortest path for a maze with a ball (the ball is rolling until it hits a wall). maze = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, …

## Smallest path from corner to corner of a 2D array

I’m working on a problem where I’m trying to get from the top left corner, i.e. (0,0), to the bottom right, or (m – 1, n – 1), of an input m x n 2D array. Additionally, each element of the array …

## Finding diameter of a graph using linear algebra or BFS

I got homework from school saying I need to find the diameter of a graph in CPP. The problem is I need to do it for 5000 graphs with 1000 vertices each. To save my graph I used vector of vectors like …

## How to find the nearest node using BFS?

Let G(V,E) be an undirected unweighted graph and r be a subset of V. Now node root is added to G and edges are added between root and all the nodes of r. Now for each node of V-r I want to find the …

## How do you use stl iterator and a queue to implement a breadth first traversal of a graph?

while I understand the BFS conceptually I haven’t grasped how to use an iterator and a queue to implement the BFS. I’d really appreciate it if somebody could give me some insight how to properly use …