So I'm doing a pretty easy assignment to figure out what's the minimum amount of steps required for a Knight Piece in chess to get to a certain point in the grid.
the input file gives me the size of the grid, starting row,starting column, ending row, ending column.
So I chose to do breadth first search to do this.
I also created a struct called coordinates so that I can save the possible ways the knight can move from the current position and I put them into a queue.
However, using this huge input file my code always gets a stack overflow when my queue has around 12794 inserted.
The code is really simple, the bulk of it is enqueing the different possible ways of the knight moving
row = A, Column = B
here's the code
[C] knight - Pastebin.com
also here's the input file, name it goldknight.in
goldknight.in - Pastebin.com
You'll notice the stack overflow on the 3rd case
I think that it might be that i'm allocating it wrong or that the memory is running out and I need to free up the space not being used.