Page 1 of 1

For the next few problems consider the code shown at right, similar to the maze program discussed in class. Note that th

Posted: Thu May 05, 2022 12:53 pm
by answerhappygod
For The Next Few Problems Consider The Code Shown At Right Similar To The Maze Program Discussed In Class Note That Th 1
For The Next Few Problems Consider The Code Shown At Right Similar To The Maze Program Discussed In Class Note That Th 1 (62.35 KiB) Viewed 45 times
For the next few problems consider the code shown at right, similar to the maze program discussed in class. Note that the order of attempting moves is the reverse of what we used in class and is: down, right, up, left. Also added is an extra condition check (in bold) to avoid visiting a node that we've been to before, to avoid infinite looping. int start 11: int goal 54; int movesSize - 4: int mazell- /* The code is called using: +0123456789/ (1,1,1,1,1,1,1,1,1,1, 1,0,0,0,0,1,1,0,1,1, 1,1,0,1,0,1,0,0,0.1, / 0 / /*10/ /*20/ /*30/ /*40/ makeMove ( start); 1,1,0,0,0,0,0,1,0,1.. 1,1,1,0,1,0,1,0,0,1, /*50 / /*60*/ 1,1,1,1,0,0,0,0,1,1, 1,1,1,1,1,1,1,1,1,1); 20. For the program as shown, what are the first three square index values displayed? int moves []- (10.1.-10,-1); int cameFrom [70]; bool done false; void makeMove(int current) 21. If we instead had start 36 and we were not using the came From array, what would be the first three square index values displayed? cout << current << ", "; if (current -- goal) ( done = true; return; // found solution, 1 for (int i=0; i<movesSize; i++) { current + moves; int next 22. With the code shown as-is (including the came From array), consider what would happen if we switched the start and end values, starting from 55-54 and ending at 11. if( (maze [next] != 1) (next !- came From[current]) && Idone 66 came From [next]==0 } { cameFrom next] = current; makeMove ( next); After reaching and displaying the index value for square 45, what would be the single next index value displayed when running this program? //end makeMove (e.g. the output would be: 45 where this question is asking about the number in the blank after 45 is displayed.) 23. Again consider the situation described in the previous question, where we reach and display 45 and then display the single value after that. Then what is the next value to be displayed? (e.g. the output would be: 45 where this question is asking about the number in the second blank after 45 is displayed.)