0

I have a problem that I am working on, and it is to find the shortest path on a grid, when you are given a start point, an end point, and a list of obstacles. I managed to set up a grid by using a vector of vectors, but I'm having trouble in my actual recursive call. For one reason or another, my grid doesn't update when I try to pass it to this function.

The code for my recursive function is as follows

```
//grid is the grid of walls and openings, currSt is the current Y coordinate
//currAv is the current X coordinate, pathLength is the current length of the path
void findShortestPath(vector<vector<int> >& grid, int currSt,int currAv,int pathLength,int const gridSize)
{
int solutionLength;
//checks for solution
if(isSolution(grid,currSt,currAv))
{
printPath(grid,gridSize);
}
else if(isValidMove(grid,currSt,currAv-1,gridSize,pathLength,solutionLength))
{
grid[currSt][currAv-1]=pathLength;
pathLength++;
findShortestPath(grid,currSt,currAv-1,pathLength,gridSize);
}
else if(isValidMove(grid,currSt,currAv+1,gridSize,pathLength,solutionLength))
{
grid[currSt][currAv+1]=pathLength;
pathLength++;
findShortestPath(grid,currSt,currAv+1,pathLength,gridSize);
}
else if(isValidMove(grid,currSt+1,currAv,gridSize,pathLength,solutionLength))
{
grid[currSt+1][currAv]=pathLength;
pathLength++;
findShortestPath(grid,currSt+1,currAv,pathLength,gridSize);
}
else if(isValidMove(grid,currSt-1,currAv,gridSize,pathLength,solutionLength))
{
grid[currSt-1][currAv]=pathLength;
pathLength++;
findShortestPath(grid,currSt-1,currAv,pathLength,gridSize);
}
}
```